[cvs] / xvidcore / src / utils / mem_align.c Repository:
ViewVC logotype

Diff of /xvidcore/src/utils/mem_align.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2, Wed Mar 20 00:27:57 2002 UTC revision 1.3, Thu Mar 21 00:28:33 2002 UTC
# Line 18  Line 18 
18            uint8_t *tmp;            uint8_t *tmp;
19    
20            if((tmp = (uint8_t *) malloc(size + alignment)) != NULL) {            if((tmp = (uint8_t *) malloc(size + alignment)) != NULL) {
21                  mem_ptr = (uint8_t *) (((uint32_t) tmp / alignment) * alignment + alignment);                          mem_ptr = (uint8_t *)((uint32_t)(tmp + alignment - 1)&(~(uint32_t)(alignment - 1)));
22                  *(mem_ptr - 1) = (alignment - 1) - ((uint32_t) tmp % alignment);                          *(mem_ptr - 1) = (uint8_t)(mem_ptr - tmp);
23                  return (void *) mem_ptr;                  return (void *) mem_ptr;
24            }            }
25    }    }
26    
27    return NULL;    return NULL;
28    
29  }  }
30    
31  void xvid_free(void *mem_ptr)  void xvid_free(void *mem_ptr)
32  {  {
   uint8_t *tmp;  
33    
34    tmp = (uint8_t *) mem_ptr - 1;          uint8_t *real_ptr;
35    mem_ptr  = tmp - *tmp;  
36            real_ptr = (uint8_t*)mem_ptr;
37    
38            free(real_ptr - *(real_ptr -1));
39    
   free(mem_ptr);  
40  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

No admin address has been configured
ViewVC Help
Powered by ViewVC 1.0.4