1*75f6d617Schristos /* $NetBSD: realloc.c,v 1.1.1.1 2016/01/13 03:15:30 christos Exp $ */
2*75f6d617Schristos
3*75f6d617Schristos /* Work around bug on some systems where realloc (NULL, 0) fails.
4*75f6d617Schristos Copyright (C) 1997 Free Software Foundation, Inc.
5*75f6d617Schristos
6*75f6d617Schristos This program is free software; you can redistribute it and/or modify
7*75f6d617Schristos it under the terms of the GNU General Public License as published by
8*75f6d617Schristos the Free Software Foundation; either version 2, or (at your option)
9*75f6d617Schristos any later version.
10*75f6d617Schristos
11*75f6d617Schristos This program is distributed in the hope that it will be useful,
12*75f6d617Schristos but WITHOUT ANY WARRANTY; without even the implied warranty of
13*75f6d617Schristos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14*75f6d617Schristos GNU General Public License for more details.
15*75f6d617Schristos
16*75f6d617Schristos You should have received a copy of the GNU General Public License
17*75f6d617Schristos along with this program; if not, write to the Free Software Foundation,
18*75f6d617Schristos Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
19*75f6d617Schristos
20*75f6d617Schristos /* written by Jim Meyering */
21*75f6d617Schristos
22*75f6d617Schristos #if HAVE_CONFIG_H
23*75f6d617Schristos # include <config.h>
24*75f6d617Schristos #endif
25*75f6d617Schristos #undef realloc
26*75f6d617Schristos
27*75f6d617Schristos #include <sys/types.h>
28*75f6d617Schristos
29*75f6d617Schristos char *malloc ();
30*75f6d617Schristos char *realloc ();
31*75f6d617Schristos
32*75f6d617Schristos /* Change the size of an allocated block of memory P to N bytes,
33*75f6d617Schristos with error checking. If N is zero, change it to 1. If P is NULL,
34*75f6d617Schristos use malloc. */
35*75f6d617Schristos
36*75f6d617Schristos char *
rpl_realloc(p,n)37*75f6d617Schristos rpl_realloc (p, n)
38*75f6d617Schristos char *p;
39*75f6d617Schristos size_t n;
40*75f6d617Schristos {
41*75f6d617Schristos if (n == 0)
42*75f6d617Schristos n = 1;
43*75f6d617Schristos if (p == 0)
44*75f6d617Schristos return malloc (n);
45*75f6d617Schristos return realloc (p, n);
46*75f6d617Schristos }
47