]> mj.ucw.cz Git - libucw.git/commitdiff
xfree() macro has been turned into a regular function. This is much cleaner,
authorMartin Mares <mj@ucw.cz>
Mon, 16 Jan 2006 20:02:42 +0000 (20:02 +0000)
committerMartin Mares <mj@ucw.cz>
Mon, 16 Jan 2006 20:02:42 +0000 (20:02 +0000)
allows for easy memory allocation tracking and also avoids including
<stdlib.h> at random places.

lib/alloc.c
lib/lib.h

index 599913161b2e496d3f946922c7919ccbc4d83666..678901a98e834f330d38c97fefb7f999982afc86 100644 (file)
@@ -32,3 +32,14 @@ xmalloc_zero(uns 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);
+}
index 17944dbe2bcf9cbc12fc8886803e5a26b1e6f51b..80090971463a83b8e9902c0782b1deca94937f49 100644 (file)
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -1,7 +1,7 @@
 /*
  *     The UCW Library -- Miscellaneous Functions
  *
- *     (c) 1997--2005 Martin Mares <mj@ucw.cz>
+ *     (c) 1997--2006 Martin Mares <mj@ucw.cz>
  *     (c) 2005 Tomas Valla <tom@ucw.cz>
  *
  *     This software may be freely distributed and used according to the terms
@@ -139,7 +139,7 @@ static inline void log_switch_enable(void) { ASSERT(log_switch_nest); log_switch
  */
 void *xmalloc(unsigned);
 void *xrealloc(void *, unsigned);
-#define sh_xfree(x) free(x)
+void xfree(void *);
 #endif
 
 void *xmalloc_zero(unsigned);