Mercurial > libavcodec.hg
comparison mem.c @ 2147:f980082baeaa libavcodec
realloc(NULL) fix
author | michael |
---|---|
date | Tue, 27 Jul 2004 11:09:41 +0000 |
parents | d07784fbdad1 |
children | 18b8b2dcc037 |
comparison
equal
deleted
inserted
replaced
2146:b288cdc2ad68 | 2147:f980082baeaa |
---|---|
93 */ | 93 */ |
94 void *av_realloc(void *ptr, unsigned int size) | 94 void *av_realloc(void *ptr, unsigned int size) |
95 { | 95 { |
96 #ifdef MEMALIGN_HACK | 96 #ifdef MEMALIGN_HACK |
97 //FIXME this isnt aligned correctly though it probably isnt needed | 97 //FIXME this isnt aligned correctly though it probably isnt needed |
98 int diff= ptr ? ((char*)ptr)[-1] : 0; | 98 int diff; |
99 if(!ptr) return av_malloc(size); | |
100 diff= ((char*)ptr)[-1]; | |
99 return realloc(ptr - diff, size + diff) + diff; | 101 return realloc(ptr - diff, size + diff) + diff; |
100 #else | 102 #else |
101 return realloc(ptr, size); | 103 return realloc(ptr, size); |
102 #endif | 104 #endif |
103 } | 105 } |