]>
Commit | Line | Data |
---|---|---|
01170860 RP |
1 | /* xrealloc.c - new memory or bust |
2 | ||
3 | Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc. | |
6efd877d | 4 | |
a39116f1 | 5 | This file is part of GAS, the GNU Assembler. |
6efd877d | 6 | |
a39116f1 RP |
7 | GAS is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by | |
9 | the Free Software Foundation; either version 2, or (at your option) | |
10 | any later version. | |
6efd877d | 11 | |
a39116f1 RP |
12 | GAS is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | GNU General Public License for more details. | |
6efd877d | 16 | |
a39116f1 RP |
17 | You should have received a copy of the GNU General Public License |
18 | along with GAS; see the file COPYING. If not, write to | |
19 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
fecd2382 RP |
20 | |
21 | ||
6efd877d KR |
22 | /* |
23 | ||
a39116f1 RP |
24 | NAME |
25 | xrealloc () - get more memory or bust | |
26 | INDEX | |
27 | xrealloc () uses realloc () | |
28 | SYNOPSIS | |
29 | char *my_memory; | |
6efd877d | 30 | |
a39116f1 RP |
31 | my_memory = xrealloc (my_memory, 42); |
32 | / * my_memory gets (perhaps new) address of 42 chars * / | |
6efd877d | 33 | |
a39116f1 | 34 | DESCRIPTION |
6efd877d | 35 | |
a39116f1 RP |
36 | Use xrealloc () as an "error-free" realloc ().It does almost the same |
37 | job. When it cannot honour your request for memory it BOMBS your | |
38 | program with a "virtual memory exceeded" message. Realloc() returns | |
39 | NULL and does not bomb your program. | |
6efd877d | 40 | |
a39116f1 RP |
41 | SEE ALSO |
42 | realloc () | |
43 | */ | |
fecd2382 | 44 | |
3340f7e5 | 45 | #if __STDC__ == 1 |
fecd2382 RP |
46 | #include <stdlib.h> |
47 | #else | |
48 | #ifdef USG | |
49 | #include <malloc.h> | |
50 | #else | |
6efd877d | 51 | char *realloc (); |
fecd2382 | 52 | #endif /* USG */ |
3340f7e5 | 53 | #endif /* not __STDC__ */ |
fecd2382 RP |
54 | |
55 | #define error as_fatal | |
56 | ||
6efd877d KR |
57 | char * |
58 | xrealloc (ptr, n) | |
59 | register char *ptr; | |
60 | long n; | |
fecd2382 | 61 | { |
6efd877d KR |
62 | void error (); |
63 | ||
64 | if ((ptr = realloc (ptr, (unsigned) n)) == 0) | |
65 | error ("virtual memory exceeded"); | |
66 | return (ptr); | |
fecd2382 RP |
67 | } |
68 | ||
8b228fe9 | 69 | /* end of xrealloc.c */ |