]> mj.ucw.cz Git - libucw.git/blob - ucw/alloc.c
Hashtable: Fixed some documentation errors
[libucw.git] / ucw / alloc.c
1 /*
2  *      UCW Library -- Memory Allocation
3  *
4  *      (c) 2000 Martin Mares <mj@ucw.cz>
5  *
6  *      This software may be freely distributed and used according to the terms
7  *      of the GNU Lesser General Public License.
8  */
9
10 #include <ucw/lib.h>
11
12 #include <stdlib.h>
13 #include <string.h>
14
15 void *
16 xmalloc(size_t size)
17 {
18   void *x = malloc(size);
19   if (!x)
20     die("Cannot allocate %zu bytes of memory", size);
21   return x;
22 }
23
24 void *
25 xmalloc_zero(size_t size)
26 {
27   void *x = xmalloc(size);
28   bzero(x, size);
29   return x;
30 }
31
32 void
33 xfree(void *ptr)
34 {
35   /*
36    * Maybe it is a little waste of resources to make this a function instead
37    * of a macro, but xmalloc() is not used for anything critical anyway,
38    * so let's prefer simplicity.
39    */
40   free(ptr);
41 }