From 6e2671c45c3b152d447adce49f150d5038cc82d2 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 4 Nov 2001 23:28:59 +0000 Subject: [PATCH] implicit free - catch anyway.. and set ptr to NULL SVN revision: 5628 --- legacy/ecore/src/Ecore.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/legacy/ecore/src/Ecore.h b/legacy/ecore/src/Ecore.h index 1fbaca51a4..6cc8ddef5a 100644 --- a/legacy/ecore/src/Ecore.h +++ b/legacy/ecore/src/Ecore.h @@ -58,12 +58,14 @@ {if (dat) FREE(dat);} #define REALLOC(dat, type, num) \ { \ - if (dat) dat = realloc((dat), sizeof(type) * (num)); \ + if ((dat) && (num == 0)) {free(dat); dat = NULL;} \ + else if (dat) dat = realloc((dat), sizeof(type) * (num)); \ else dat = malloc(sizeof(type) * (num)); \ } #define REALLOC_PTR(dat, num) \ { \ - if (dat) dat = realloc(dat, sizeof(void *) * (num)); \ + if ((dat) && (num == 0)) {free(dat); dat = NULL;} \ + else if (dat) dat = realloc(dat, sizeof(void *) * (num)); \ else dat = malloc(sizeof(void *) * (num)); \ }