1
0
Fork 0
forked from len0rd/rockbox

More standard conforming codec_realloc()

- Leave original ptr untouched if allocation fails
  (bail out early)
- Behave like malloc() in case ptr is NULL

Change-Id: Ib854ca19bd0e069999b7780d2d9a533ece705add
This commit is contained in:
Thomas Jarosch 2014-12-27 17:33:24 +01:00
parent d68262eede
commit e7c282fed7

View file

@ -91,8 +91,12 @@ void* codec_realloc(void* ptr, size_t size)
{ {
void* x; void* x;
x = codec_malloc(size); x = codec_malloc(size);
ci->memcpy(x, ptr, size); if (x == NULL)
codec_free(ptr); return NULL;
if (ptr) {
ci->memcpy(x, ptr, size);
codec_free(ptr);
}
return(x); return(x);
} }