[lib] Experimental: have XFREE NULL out the freed pointer

2006-06-15 Paul Jakma <paul.jakma@sun.com>

	* memory.h: Experimental, have XFREE macro NULL out the freed
	  pointer.
diff --git a/lib/ChangeLog b/lib/ChangeLog
index b2ec068..b7c9f04 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,6 +1,8 @@
 2006-06-15 Paul Jakma <paul.jakma@sun.com>
 
 	* command.c: (cmd_describe_command_real) Fix leak, CID #38.
+	* memory.h: Experimental, have XFREE macro NULL out the freed
+	  pointer.
 
 2006-05-28 Paul Jakma <paul.jakma@sun.com>
 
diff --git a/lib/memory.h b/lib/memory.h
index 071f394..a23c278 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -53,7 +53,10 @@
 #define XMALLOC(mtype, size)       zmalloc ((mtype), (size))
 #define XCALLOC(mtype, size)       zcalloc ((mtype), (size))
 #define XREALLOC(mtype, ptr, size) zrealloc ((mtype), (ptr), (size))
-#define XFREE(mtype, ptr)          zfree ((mtype), (ptr))
+#define XFREE(mtype, ptr)          do { \
+                                     zfree ((mtype), (ptr)); \
+                                     ptr = NULL; } \
+                                   while (0)
 #define XSTRDUP(mtype, str)        zstrdup ((mtype), (str))
 #endif /* MEMORY_LOG */