implicit free - catch anyway.. and set ptr to NULL

SVN revision: 5628
This commit is contained in:
Carsten Haitzler 2001-11-04 23:28:59 +00:00
parent 5665ed7023
commit 6e2671c45c
1 changed files with 4 additions and 2 deletions

View File

@ -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)); \
}