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:
parent
d68262eede
commit
e7c282fed7
1 changed files with 6 additions and 2 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue