simplify pic_default_alloc impl

This commit is contained in:
Yuichi Nishiwaki 2015-08-10 21:17:26 +09:00
parent c573f2c56e
commit c139bb0f08
1 changed files with 3 additions and 9 deletions

View File

@ -83,17 +83,11 @@ pic_heap_close(pic_state *pic, struct pic_heap *heap)
void * void *
pic_default_allocf(void PIC_UNUSED(*userdata), void *ptr, size_t size) pic_default_allocf(void PIC_UNUSED(*userdata), void *ptr, size_t size)
{ {
if (size == 0) { if (size != 0) {
if (ptr) {
free(ptr);
}
return NULL;
}
if (ptr) {
return realloc(ptr, size); return realloc(ptr, size);
} else {
return malloc(size);
} }
free(ptr);
return NULL;
} }
#endif #endif