X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=inline;f=ucw%2Falloc.c;h=816da2a055cfe25d21a135aacd5604a16f219d3b;hb=959566090f98dd31eaa67d3d5959b641e5fe902b;hp=4562b81521a4340d6845b57e0ca1ab698df75bf4;hpb=e6688eeb82d349a202a30a243a59079bdc4c212d;p=libucw.git diff --git a/ucw/alloc.c b/ucw/alloc.c index 4562b815..816da2a0 100644 --- a/ucw/alloc.c +++ b/ucw/alloc.c @@ -7,7 +7,7 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" +#include #include #include @@ -22,7 +22,7 @@ xmalloc(size_t size) } void * -xmalloc_zero(uns size) +xmalloc_zero(size_t size) { void *x = xmalloc(size); bzero(x, size); @@ -39,3 +39,13 @@ xfree(void *ptr) */ free(ptr); } + +void * +xrealloc(void *old, size_t size) +{ + /* We assume that realloc(NULL, x) works like malloc(x), which is true with the glibc. */ + void *x = realloc(old, size); + if (!x && size) + die("Cannot reallocate %zu bytes of memory", size); + return x; +}