summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2006-03-26 17:53:56 +0300
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2006-03-29 08:55:21 +0000
commit7e337ee0bc836d3147f3b2579c7e35127637e377 (patch)
treec29b93e66e8deb1fbf7132063cb81a86f7671650 /handy.h
parent5247441a32fa99437809b483eb208756c7ad2401 (diff)
downloadperl-7e337ee0bc836d3147f3b2579c7e35127637e377.tar.gz
re-[PATCH] Re: [PATCH] Poison now in two different flavours!
Message-ID: <442680D4.3000809@gmail.com> p4raw-id: //depot/perl@27626
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/handy.h b/handy.h
index 66ce4d125c..010cd9a622 100644
--- a/handy.h
+++ b/handy.h
@@ -617,10 +617,22 @@ optimise.
=for apidoc Am|void|StructCopy|type src|type dest|type
This is an architecture-independent macro to copy one structure to another.
+=for apidoc Am|void|PoisonWith|void* dest|int nitems|type|U8 byte
+
+Fill up memory with a byte pattern (a byte repeated over and over
+again) that hopefully catches attempts to access uninitialized memory.
+
+=for apidoc Am|void|PoisonNew|void* dest|int nitems|type
+
+PoisonWith(0xAB) for catching access to allocated but uninitialized memory.
+
+=for apidoc Am|void|Poison|void* dest|int nitems|type
+
+PoisonWith(0xEF) for catching access to freed memory.
+
=for apidoc Am|void|Poison|void* dest|int nitems|type
-Fill up memory with a pattern (byte 0xAB over and over again) that
-hopefully catches attempts to access uninitialized memory.
+PoisonWith(0xEF) for catching access to freed memory.
=cut */
@@ -740,7 +752,10 @@ Malloc_t Perl_mem_log_free(Malloc_t oldalloc, const char *filename, const int li
#define ZeroD(d,n,t) (MEM_WRAP_CHECK_(n,t) memzero((char*)(d), (n) * sizeof(t)),d)
#endif
-#define Poison(d,n,t) (MEM_WRAP_CHECK_(n,t) (void)memset((char*)(d), 0xAB, (n) * sizeof(t)))
+#define PoisonWith(d,n,t,b) (MEM_WRAP_CHECK_(n,t) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)))
+#define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB)
+#define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF)
+#define Poison(d,n,t) PoisonFree(d,n,t)
#ifdef USE_STRUCT_COPY
#define StructCopy(s,d,t) (*((t*)(d)) = *((t*)(s)))