]> mj.ucw.cz Git - libucw.git/blobdiff - lib/alloc.c
Try to merge recent changes in v3.9 to image branch...
[libucw.git] / lib / alloc.c
index 65594669234328ad0316a2b956d2434f815479b9..678901a98e834f330d38c97fefb7f999982afc86 100644 (file)
@@ -1,19 +1,45 @@
 /*
- *     Sherlock Library -- Memory Allocation
+ *     UCW Library -- Memory Allocation
  *
- *     (c) 1997 Martin Mares, <mj@atrey.karlin.mff.cuni.cz>
+ *     (c) 2000 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
-#include <stdio.h>
+#include "lib/lib.h"
+
 #include <stdlib.h>
+#include <string.h>
 
-#include "lib.h"
+#ifndef DEBUG_DMALLOC
 
 void *
 xmalloc(uns size)
 {
   void *x = malloc(size);
   if (!x)
-       die("Cannot allocate %d bytes of memory", 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);
+}