summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-06-23 14:11:20 +0000
committerNicholas Clark <nick@ccl4.org>2005-06-23 14:11:20 +0000
commit94010e71b67db04027249ff69e2a2bfa9a050945 (patch)
tree3288295ac02b3ed67238e92114987299ead8ffc3 /handy.h
parent771ba71a7bf3673decf297992c8591f2ff873802 (diff)
downloadperl-94010e71b67db04027249ff69e2a2bfa9a050945.tar.gz
Add a define PERL_POISON which tries to trip up anything accessing
freed or uninitialised memory. Currently only Poison()s freed pointers. p4raw-id: //depot/perl@24959
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/handy.h b/handy.h
index 534e92e7b1..0a2c50e26c 100644
--- a/handy.h
+++ b/handy.h
@@ -626,7 +626,13 @@ hopefully catches attempts to access uninitialized memory.
(v = (MEM_WRAP_CHECK_(n,t) (t*)saferealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t)))))
#define Renewc(v,n,t,c) \
(v = (MEM_WRAP_CHECK_(n,t) (c*)saferealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t)))))
+
+#ifdef PERL_POISON
+#define Safefree(d) \
+ (d ? (void)(safefree((Malloc_t)(d)), Poison(&(d), 1, Malloc_t)) : (void) 0)
+#else
#define Safefree(d) safefree((Malloc_t)(d))
+#endif
#define Move(s,d,n,t) (MEM_WRAP_CHECK_(n,t) (void)memmove((char*)(d),(const char*)(s), (n) * sizeof(t)))
#define Copy(s,d,n,t) (MEM_WRAP_CHECK_(n,t) (void)memcpy((char*)(d),(const char*)(s), (n) * sizeof(t)))