From 2c27563b528310adb8c5216161953171a664043b Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 21 Jan 2001 11:07:40 +0000 Subject: [PATCH] Introduced xmalloc_zero(). --- lib/alloc.c | 9 +++++++++ lib/lib.h | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/alloc.c b/lib/alloc.c index bec45d9b..07532143 100644 --- a/lib/alloc.c +++ b/lib/alloc.c @@ -7,6 +7,7 @@ #include "lib/lib.h" #include +#include void * xmalloc(uns size) @@ -16,3 +17,11 @@ xmalloc(uns size) die("Cannot allocate %d bytes of memory", size); return x; } + +void * +xmalloc_zero(uns size) +{ + void *x = xmalloc(size); + bzero(x, size); + return x; +} diff --git a/lib/lib.h b/lib/lib.h index a6de298a..7fa13e79 100644 --- a/lib/lib.h +++ b/lib/lib.h @@ -92,6 +92,7 @@ void log_file(byte *); */ #define xmalloc sh_xmalloc void *xmalloc(unsigned); +void *xmalloc_zero(unsigned); void *xrealloc(void *, unsigned); #define xfree(x) free(x) #endif -- 2.39.2