mirror of
https://github.com/westes/flex.git
synced 2026-01-26 15:39:06 +00:00
30 lines
344 B
C
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;
|
|
}
|