flex/lib/realloc.c
Michael Haubenwallner 6c429958e7 Fix malloc/realloc replacement, bug#151.
Signed-off-by: Will Estes <westes575@gmail.com>
2014-04-02 16:51:22 -04:00

30 lines
344 B
C

#include <config.h>
#undef realloc
#undef malloc
#include <stdlib.h>
#include <errno.h>
void * rpl_realloc (void *p, size_t n)
{
void *result;
if (n == 0)
{
n = 1;
}
if (p == NULL)
{
result = malloc (n);
}
else
result = realloc (p, n);
if (result == NULL)
errno = ENOMEM;
return result;
}