2999
|
1 /* xrealloc.c: realloc with error checking. |
|
2 |
|
3 Copyright (C) 1992, 93 Free Software Foundation, Inc. |
|
4 |
|
5 This library 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 This library 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 this library; if not, write to the Free Software |
|
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ |
|
18 |
3172
|
19 #include <stdio.h> |
|
20 #include <kpathsea/config.h> |
2999
|
21 |
3172
|
22 extern void *xmalloc P1H(unsigned); |
2999
|
23 |
|
24 void * |
3172
|
25 xrealloc P2C(void *, old_ptr, unsigned, size) |
2999
|
26 { |
|
27 void *new_mem; |
|
28 |
|
29 if (old_ptr == NULL) |
|
30 new_mem = xmalloc (size); |
|
31 else |
|
32 { |
|
33 new_mem = (void *) realloc (old_ptr, size); |
|
34 if (new_mem == NULL) |
|
35 { |
|
36 /* We used to print OLD_PTR here using %x, and casting its |
|
37 value to unsigned, but that lost on the Alpha, where |
|
38 pointers and unsigned had different sizes. Since the info |
|
39 is of little or no value anyway, just don't print it. */ |
|
40 fprintf (stderr, "fatal: memory exhausted (realloc of %u bytes).\n", |
|
41 size); |
|
42 /* 1 means success on VMS, so pick a random number (ASCII `B'). */ |
|
43 exit (66); |
|
44 } |
|
45 } |
|
46 |
|
47 return new_mem; |
|
48 } |