From: Ivo Timmermans Date: Thu, 16 Nov 2000 18:06:39 +0000 (+0000) Subject: New function: xmalloc_and_zero, which initialises the allocated memory X-Git-Tag: release-1.0pre4~171 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=30f34015ee11bbe1106c07e381288a702f12dac5;p=oweals%2Ftinc.git New function: xmalloc_and_zero, which initialises the allocated memory to all zeroes. --- diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 150b1aa..037fab8 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -94,6 +94,21 @@ xmalloc (n) return p; } +/* Allocate N bytes of memory dynamically, and set it all to zero. */ + +void * +xmalloc_and_zero (n) + size_t n; +{ + void *p; + + p = malloc (n); + if (p == 0) + xalloc_fail ((int)n); + memset (p, '\0', n); + return p; +} + /* Change the size of an allocated block of memory P to N bytes, with error checking. If P is NULL, run xmalloc. */