X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Falloc.c;h=678901a98e834f330d38c97fefb7f999982afc86;hb=86919305a08aa88b3a60c3216752291ba7f0b496;hp=bec45d9b590f691050aa7722cc746af63c91c640;hpb=1571781022499a9d0c32d249f89945d034d1cbff;p=libucw.git diff --git a/lib/alloc.c b/lib/alloc.c index bec45d9b..678901a9 100644 --- a/lib/alloc.c +++ b/lib/alloc.c @@ -1,12 +1,18 @@ /* - * Sherlock Library -- Memory Allocation + * UCW Library -- Memory Allocation * * (c) 2000 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #include "lib/lib.h" #include +#include + +#ifndef DEBUG_DMALLOC void * xmalloc(uns size) @@ -16,3 +22,24 @@ xmalloc(uns size) die("Cannot allocate %d bytes of memory", size); return x; } + +#endif + +void * +xmalloc_zero(uns size) +{ + void *x = xmalloc(size); + bzero(x, size); + return x; +} + +void +xfree(void *ptr) +{ + /* + * Maybe it is a little waste of resources to make this a function instead + * of a macro, but xmalloc() is not used for anything critical anyway, + * so let's prefer simplicity. + */ + free(ptr); +}