pci: don't do sanity check for missing pci bus, the check can misfire.
[minix.git] / commands / flex-2.5.4 / MISC / Macintosh / xmalloc.c
blob5bef8319783f91e539e4e8df523c98430148137a
1 /* xmalloc.c -- malloc with out of memory checking
2 Copyright (C) 1990, 1991 Free Software Foundation, Inc.
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
18 #if STDC_HEADERS || THINK_C
19 #include <stdlib.h>
20 #else
21 char *malloc ();
22 char *realloc ();
23 void free ();
24 #endif
26 #ifdef THINK_C
27 #define error(x, y, z) perror(z) /* Throw out meaningless arguments */
28 #else
29 void error ();
30 #endif
32 /* Allocate N bytes of memory dynamically, with error checking. */
34 char *
35 xmalloc (n)
36 unsigned n;
38 char *p;
40 p = malloc (n);
41 if (p == 0)
42 /* Must exit with 2 for `cmp'. */
43 error (2, 0, "virtual memory exhausted");
44 return p;
47 /* Change the size of an allocated block of memory P to N bytes,
48 with error checking.
49 If P is NULL, run xmalloc.
50 If N is 0, run free and return NULL. */
52 char *
53 xrealloc (p, n)
54 char *p;
55 unsigned n;
57 if (p == 0)
58 return xmalloc (n);
59 if (n == 0)
61 free (p);
62 return 0;
64 p = realloc (p, n);
65 if (p == 0)
66 /* Must exit with 2 for `cmp'. */
67 error (2, 0, "virtual memory exhausted");
68 return p;