From c139bb0f08499103b1cedab87403c5590e9b82cc Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Mon, 10 Aug 2015 21:17:26 +0900 Subject: [PATCH] simplify pic_default_alloc impl --- extlib/benz/gc.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/extlib/benz/gc.c b/extlib/benz/gc.c index 913cf817..c2345ace 100644 --- a/extlib/benz/gc.c +++ b/extlib/benz/gc.c @@ -83,17 +83,11 @@ pic_heap_close(pic_state *pic, struct pic_heap *heap) void * pic_default_allocf(void PIC_UNUSED(*userdata), void *ptr, size_t size) { - if (size == 0) { - if (ptr) { - free(ptr); - } - return NULL; - } - if (ptr) { + if (size != 0) { return realloc(ptr, size); - } else { - return malloc(size); } + free(ptr); + return NULL; } #endif