gcc41: update README.DELETED
[dragonfly.git] / contrib / texinfo-4 / lib / xmalloc.c
blobb91e4fce633b8c469e8bc105441650ac1033e93f
1 /* xmalloc.c -- safe versions of malloc and realloc.
3 Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 2004 Free Software
4 Foundation, Inc.
6 This program 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.
11 This program 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.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 Written by Brian Fox (bfox@ai.mit.edu). */
22 #if !defined (ALREADY_HAVE_XMALLOC)
23 #include "system.h"
25 static void
26 memory_error_and_abort (const char *fname)
28 fprintf (stderr, "%s: Out of virtual memory!\n", fname);
29 abort ();
32 /* Return a pointer to free()able block of memory large enough
33 to hold BYTES number of bytes. If the memory cannot be allocated,
34 print an error message and abort. */
35 void *
36 xmalloc (size_t bytes)
38 void *temp = malloc (bytes);
40 if (!temp)
41 memory_error_and_abort ("xmalloc");
42 return (temp);
45 void *
46 xrealloc (void *pointer, size_t bytes)
48 void *temp;
50 if (!pointer)
51 temp = malloc (bytes);
52 else
53 temp = realloc (pointer, bytes);
55 if (!temp)
56 memory_error_and_abort ("xrealloc");
58 return (temp);
61 #endif /* !ALREADY_HAVE_XMALLOC */