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