summaryrefslogtreecommitdiff
path: root/lib/memory.h
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-06-15 12:41:02 +0000
committerPaul Jakma <paul.jakma@sun.com>2006-06-15 12:41:02 +0000
commit8ce5cfd13eb7f8474b3129a57c160273889c2573 (patch)
tree314dba4d94fe3a47fe188a700adbb73fee0ab4d8 /lib/memory.h
parente5cd706c1a4b8138e9b78933e03460f0b032c77e (diff)
[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.
Diffstat (limited to 'lib/memory.h')
-rw-r--r--lib/memory.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/memory.h b/lib/memory.h
index 071f394e..a23c2787 100644
--- a/lib/memory.h
+++ b/lib/memory.h
@@ -53,7 +53,10 @@ extern struct mlist mlists[];
#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 */