mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-13 18:17:39 -04:00
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;
|
||||
x = codec_malloc(size);
|
||||
ci->memcpy(x, ptr, size);
|
||||
codec_free(ptr);
|
||||
if (x == NULL)
|
||||
return NULL;
|
||||
if (ptr) {
|
||||
ci->memcpy(x, ptr, size);
|
||||
codec_free(ptr);
|
||||
}
|
||||
return(x);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue