]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gas/xmalloc.c
White space and comment changes. #ifdef __STDC__ becomes #if __STDC__
[thirdparty/binutils-gdb.git] / gas / xmalloc.c
CommitLineData
fecd2382 1/* xmalloc.c - get memory or bust
01170860
RP
2
3 Copyright (C) 1987, 1990, 1991, 1992 Free Software Foundation, Inc.
a39116f1
RP
4
5 This file is part of GAS, the GNU Assembler.
6
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.
11
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.
16
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 20
fecd2382 21/*
a39116f1
RP
22 NAME
23 xmalloc() - get memory or bust
24 INDEX
25 xmalloc() uses malloc()
26
27 SYNOPSIS
28 char * my_memory;
29
30 my_memory = xmalloc(42); / * my_memory gets address of 42 chars * /
31
32 DESCRIPTION
33
34 Use xmalloc() as an "error-free" malloc(). It does almost the same job.
35 When it cannot honour your request for memory it BOMBS your program
36 with a "virtual memory exceeded" message. Malloc() returns NULL and
37 does not bomb your program.
38
39 SEE ALSO
40 malloc()
41
42 */
fecd2382
RP
43#include <stdio.h>
44
3340f7e5 45#if __STDC__ == 1
fecd2382
RP
46#include <stdlib.h>
47#else
48#ifdef USG
49#include <malloc.h>
50#else
a39116f1 51char * malloc();
fecd2382 52#endif /* USG */
3340f7e5 53#endif /* not __STDC__ */
fecd2382
RP
54
55#define error as_fatal
56
57char * xmalloc(n)
a39116f1 58long n;
fecd2382 59{
a39116f1
RP
60 char * retval;
61 void error();
62
63 if ((retval = malloc ((unsigned)n)) == NULL)
64 {
65 error("virtual memory exceeded");
66 }
67 return (retval);
fecd2382
RP
68}
69
8b228fe9 70/* end of xmalloc.c */