aboutsummaryrefslogtreecommitdiffstats
path: root/epan/emem.c
diff options
context:
space:
mode:
authorJeff Morriss <jeff.morriss@ulticom.com>2009-10-20 17:43:05 +0000
committerJeff Morriss <jeff.morriss@ulticom.com>2009-10-20 17:43:05 +0000
commit78318b32ee83e2e2834a2a38d1ad1abcbf716ac2 (patch)
tree20af9bf5a0c20b896b67c0572499d79448297be1 /epan/emem.c
parent8ec5a160ecbe147ef92b86d0595703dd4ebe36da (diff)
Add emem_init() which initializes both the ep_ and se_ allocators; have all
callers use that instead of initializing each allocator individually. svn path=/trunk/; revision=30646
Diffstat (limited to 'epan/emem.c')
-rw-r--r--epan/emem.c54
1 files changed, 32 insertions, 22 deletions
diff --git a/epan/emem.c b/epan/emem.c
index 9fb6fb3a95..dc8d11b480 100644
--- a/epan/emem.c
+++ b/epan/emem.c
@@ -257,7 +257,7 @@ emem_init_chunk(emem_header_t *mem)
* This function should be called only once when Wireshark or TShark starts
* up.
*/
-void
+static void
ep_init_chunk(void)
{
ep_packet_mem.free_list=NULL;
@@ -272,6 +272,37 @@ ep_init_chunk(void)
#endif
emem_init_chunk(&ep_packet_mem);
+}
+
+/* Initialize the capture-lifetime memory allocation pool.
+ * This function should be called only once when Wireshark or TShark starts
+ * up.
+ */
+static void
+se_init_chunk(void)
+{
+ se_packet_mem.free_list = NULL;
+ se_packet_mem.used_list = NULL;
+ ep_packet_mem.trees = NULL;
+
+ se_packet_mem.debug_use_chunks = (getenv("WIRESHARK_DEBUG_SE_NO_CHUNKS") == NULL);
+ se_packet_mem.debug_use_canary = se_packet_mem.debug_use_chunks && (getenv("WIRESHARK_DEBUG_SE_USE_CANARY") != NULL);
+
+ emem_init_chunk(&se_packet_mem);
+}
+
+/* Initialize all the allocators here.
+ * This function should be called only once when Wireshark or TShark starts
+ * up.
+ */
+void
+emem_init(void)
+{
+ ep_init_chunk();
+ se_init_chunk();
+
+ if (getenv("WIRESHARK_DEBUG_SCRUB_MEMORY"))
+ debug_use_memory_scrubber = TRUE;
#if defined (_WIN32)
/* Set up our guard page info for Win32 */
@@ -298,27 +329,6 @@ ep_init_chunk(void)
#endif /* _WIN32 / USE_GUARD_PAGES */
}
-/* Initialize the capture-lifetime memory allocation pool.
- * This function should be called only once when Wireshark or TShark starts
- * up.
- */
-void
-se_init_chunk(void)
-{
- se_packet_mem.free_list = NULL;
- se_packet_mem.used_list = NULL;
- ep_packet_mem.trees = NULL;
-
- se_packet_mem.debug_use_chunks = (getenv("WIRESHARK_DEBUG_SE_NO_CHUNKS") == NULL);
- se_packet_mem.debug_use_canary = se_packet_mem.debug_use_chunks && (getenv("WIRESHARK_DEBUG_SE_USE_CANARY") != NULL);
-
- emem_init_chunk(&se_packet_mem);
-
- /* This isn't specific to se_ memory, but need to init it somewhere.. */
- if (getenv("WIRESHARK_DEBUG_SCRUB_MEMORY"))
- debug_use_memory_scrubber = TRUE;
-}
-
#ifdef SHOW_EMEM_STATS
#define NUM_ALLOC_DIST 10
static guint allocations[NUM_ALLOC_DIST] = { 0 };