Debian Codegraph @

lib/xmalloc.c

raw symbols SCIP
1 /* $Id: xmalloc.c,v 1.4 1999/03/10 07:57:53 boyns Exp $ */
2
3 /*
4 * Copyright (C) 1993-99 Mark R. Boyns <[email protected]>
5 *
6 * This file is part of rplay.
7 *
8 * rplay is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * rplay is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with rplay; see the file COPYING. If not, write to the
20 * Free Software Foundation, Inc.,
21 * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24 #include "ansidecl.h"
25 #include <stdlib.h>
26 #include <stdio.h>
27 #ifdef __STDC__
28 #include <stddef.h>
29 #else
30 #define size_t unsigned long
31 #endif
32
33 #ifdef __STDC__
34 PTR
35 xmalloc(size_t size)
36 #else
37 PTR
38 xmalloc(size)
39 size_t size;
40 #endif
41 {
42 PTR p;
43
44 p = (PTR) malloc(size);
45 if (p == 0)
46 {
47 fprintf(stderr, "xmalloc: Virtual memory exhausted.\n");
48 exit(1);
49 }
50 return p;
51 }
52
53 #ifdef __STDC__
54 PTR
55 xrealloc(PTR oldmem, size_t size)
56 #else
57 PTR
58 xrealloc(oldmem, size)
59 PTR oldmem;
60 size_t size;
61 #endif
62 {
63 PTR newmem;
64
65 if (size == 0)
66 {
67 size = 1;
68 }
69
70 newmem = (oldmem) ? (PTR) realloc(oldmem, size) : (PTR) malloc(size);
71
72 if (!newmem)
73 {
74 fprintf(stderr, "xrealloc: Virtual memory exhausted.\n");
75 exit(1);
76 }
77
78 return newmem;
79 }