|
|
1.1 root 1: /* memory allocation routines with error checking.
2: Copyright 1989, 1991, 1993 Free Software Foundation, Inc.
3:
4: This file is part of the libiberty library.
5: Libiberty is free software; you can redistribute it and/or
6: modify it under the terms of the GNU Library General Public
7: License as published by the Free Software Foundation; either
8: version 2 of the License, or (at your option) any later version.
9:
10: Libiberty is distributed in the hope that it will be useful,
11: but WITHOUT ANY WARRANTY; without even the implied warranty of
12: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: Library General Public License for more details.
14:
15: You should have received a copy of the GNU Library General Public
16: License along with libiberty; see the file COPYING.LIB. If
17: not, write to the Free Software Foundation, Inc., 675 Mass Ave,
18: Cambridge, MA 02139, USA. */
19:
20: #include <ansidecl.h>
21:
22: #include <stdio.h>
23:
24: #ifdef __STDC__
25: #include <stddef.h>
26: #else
27: #define size_t unsigned long
28: #endif
29:
30:
31: PTR
32: xmalloc (size)
33: size_t size;
34: {
35: char * newmem;
36:
37: if ((newmem = (char *) malloc ((int) size)) == NULL)
38: {
39: fprintf (stderr, "\nCan't allocate %u bytes\n", size);
40: exit (1);
41: }
42: return (newmem);
43: }
44:
45: PTR
46: xrealloc (oldmem, size)
47: PTR oldmem;
48: size_t size;
49: {
50: char * newmem;
51:
52: if ((newmem = (char *) realloc ((char *) oldmem, (int) size)) == NULL)
53: {
54: fprintf (stderr, "\nCan't reallocate %u bytes\n", size);
55: exit (1);
56: }
57: return (newmem);
58: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.