]> mj.ucw.cz Git - libucw.git/commitdiff
Introduced xmalloc_zero().
authorMartin Mares <mj@ucw.cz>
Sun, 21 Jan 2001 11:07:40 +0000 (11:07 +0000)
committerMartin Mares <mj@ucw.cz>
Sun, 21 Jan 2001 11:07:40 +0000 (11:07 +0000)
lib/alloc.c
lib/lib.h

index bec45d9b590f691050aa7722cc746af63c91c640..075321436c44f1dba1ffb54d5098d5248fd60b64 100644 (file)
@@ -7,6 +7,7 @@
 #include "lib/lib.h"
 
 #include <stdlib.h>
+#include <string.h>
 
 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;
+}
index a6de298a29a7fcb31020cf95b0868ee11df8a5cc..7fa13e79972d5cd85c482f45e6b8731173efce46 100644 (file)
--- 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