]>
git.ipfire.org Git - thirdparty/bird.git/blob - lib/xmalloc.c
2 * BIRD Library -- malloc() With Checking
4 * (c) 1998--2000 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
11 #include "nest/bird.h"
12 #include "lib/resource.h"
14 #ifndef HAVE_LIBDMALLOC
17 * xmalloc - malloc with checking
20 * This function is equivalent to malloc() except that in case of
21 * failure it calls die() to quit the program instead of returning
24 * Wherever possible, please use the memory resources instead.
27 xmalloc(unsigned size
)
29 void *p
= malloc(size
);
32 die("Unable to allocate %d bytes of memory", size
);
36 * xrealloc - realloc with checking
37 * @ptr: original memory block
40 * This function is equivalent to realloc() except that in case of
41 * failure it calls die() to quit the program instead of returning
44 * Wherever possible, please use the memory resources instead.
47 xrealloc(void *ptr
, unsigned size
)
49 void *p
= realloc(ptr
, size
);
52 die("Unable to allocate %d bytes of memory", size
);