]> git.ipfire.org Git - thirdparty/bird.git/blob - lib/xmalloc.c
Spelling fixes to progdoc.
[thirdparty/bird.git] / lib / xmalloc.c
1 /*
2 * BIRD Library -- malloc() With Checking
3 *
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
5 *
6 * Can be freely distributed and used under the terms of the GNU GPL.
7 */
8
9 #include <stdlib.h>
10
11 #include "nest/bird.h"
12 #include "lib/resource.h"
13
14 #ifndef HAVE_LIBDMALLOC
15
16 /**
17 * xmalloc - malloc with checking
18 * @size: block size
19 *
20 * This function is equivalent to malloc() except that in case of
21 * failure it calls die() to quit the program instead of returning
22 * a %NULL pointer.
23 *
24 * Wherever possible, please use the memory resources instead.
25 */
26 void *
27 xmalloc(unsigned size)
28 {
29 void *p = malloc(size);
30 if (p)
31 return p;
32 die("Unable to allocate %d bytes of memory", size);
33 }
34
35 #endif