diff options
-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 |