diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-03-10 05:15:52 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-03-10 05:15:52 +0000 |
commit | eec9a1e95ad2dbe8a459b1f68f7fda8ac3cfd1cb (patch) | |
tree | f3f4dc4f3b260338cf9b22e2237e8c14dd685ce6 | |
parent | 0afb8cd493cf4769382de52b1f327f5bb0966082 (diff) |
add a define that controls explicitely whether we want to use guard pages (if available) or not.
let it default to want-guard-pages since the existing code does that.
svn path=/trunk/; revision=17562
-rw-r--r-- | epan/emem.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/epan/emem.c b/epan/emem.c index d7951499ab..d9639d96c8 100644 --- a/epan/emem.c +++ b/epan/emem.c @@ -50,6 +50,19 @@ #include "emem.h" #include <wiretap/file_util.h> + +/* + * Tools like Valgrind and ElectricFence don't work well with memchunks. + * Uncomment the defines below to make {ep|se}_alloc() allocate each + * object individually. + */ +/* #define EP_DEBUG_FREE 1 */ +/* #define SE_DEBUG_FREE 1 */ + +/* Do we want to use guardpages? if available */ +#define WANT_GUARD_PAGES 1 + +#ifdef WANT_GUARD_PAGES /* Add guard pages at each end of our allocated memory */ #if defined(HAVE_SYSCONF) && defined(HAVE_MMAP) && defined(HAVE_MPROTECT) && defined(HAVE_STDINT_H) #include <stdint.h> @@ -57,6 +70,7 @@ #include <sys/mman.h> #define USE_GUARD_PAGES 1 #endif +#endif /* When required, allocate more memory from the OS in this size chunks */ #define EMEM_PACKET_CHUNK_SIZE 10485760 @@ -64,17 +78,6 @@ /* The maximum number of allocations per chunk */ #define EMEM_ALLOCS_PER_CHUNK (EMEM_PACKET_CHUNK_SIZE / 512) -/* - * Tools like Valgrind and ElectricFence don't work well with memchunks. - * Uncomment the defines below to make {ep|se}_alloc() allocate each - * object individually. - */ -/* #define EP_DEBUG_FREE 1 */ -/* #define SE_DEBUG_FREE 1 */ - -#if GLIB_MAJOR_VERSION >= 2 -GRand *rand_state = NULL; -#endif #define EMEM_CANARY_SIZE 8 #define EMEM_CANARY_DATA_SIZE (EMEM_CANARY_SIZE * 2 - 1) @@ -109,6 +112,10 @@ static emem_header_t se_packet_mem; void emem_canary(guint8 *canary) { int i; +#if GLIB_MAJOR_VERSION >= 2 + static GRand *rand_state = NULL; +#endif + /* First, use GLib's random function if we have it */ #if GLIB_MAJOR_VERSION >= 2 |