xref: /minix3/external/bsd/flex/dist/lib/realloc.c (revision c9ea9e7af84fcba485b32ccd2c85edb945b1f323)
1 /*	$NetBSD: realloc.c,v 1.1.1.1 2013/04/06 14:05:53 christos Exp $	*/
2 
3 #include <config.h>
4 
5 #include <stdlib.h>
6 
7 #include <errno.h>
8 
9 void * rpl_realloc (void *p, size_t n)
10 {
11   void *result;
12 
13   if (n == 0)
14     {
15       n = 1;
16     }
17 
18   if (p == NULL)
19     {
20       result = malloc (n);
21     }
22   else
23     result = realloc (p, n);
24 
25   if (result == NULL)
26     errno = ENOMEM;
27 
28   return result;
29 }
30