From f12ef91219fb2aa5f4e5638f73fc30899e9463e2 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sun, 24 Feb 2002 02:59:30 +0000 Subject: Free all the stuff pointed to by elements in the "tcp_segment_table" hash table before freeing the memory chunks for those elements. Destroy that hash table when we're done, and set the pointer to it to null so that we'll reallocate it. svn path=/trunk/; revision=4794 --- packet-tcp.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/packet-tcp.c b/packet-tcp.c index d2e5b90a48..b0b046c346 100644 --- a/packet-tcp.c +++ b/packet-tcp.c @@ -1,7 +1,7 @@ /* packet-tcp.c * Routines for TCP packet disassembly * - * $Id: packet-tcp.c,v 1.133 2002/02/19 00:14:21 guy Exp $ + * $Id: packet-tcp.c,v 1.134 2002/02/24 02:59:30 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -222,6 +222,17 @@ tcp_segment_equal(gconstpointer k1, gconstpointer k2) static void tcp_desegment_init(void) { + /* + * Free this before freeing any memory chunks; those + * chunks contain data we'll look at in "free_all_segments()". + */ + if(tcp_segment_table){ + g_hash_table_foreach_remove(tcp_segment_table, + free_all_segments, NULL); + g_hash_table_destroy(tcp_segment_table); + tcp_segment_table = NULL; + } + if(tcp_segment_key_chunk){ g_mem_chunk_destroy(tcp_segment_key_chunk); tcp_segment_key_chunk = NULL; @@ -231,20 +242,15 @@ tcp_desegment_init(void) tcp_segment_address_chunk = NULL; } - /* dont allocate any memory chunks unless the user really - uses this option + /* dont allocate any hash table or memory chunks unless the user + really uses this option */ if(!tcp_desegment){ return; } - if(tcp_segment_table){ - g_hash_table_foreach_remove(tcp_segment_table, - free_all_segments, NULL); - } else { - tcp_segment_table = g_hash_table_new(tcp_segment_hash, - tcp_segment_equal); - } + tcp_segment_table = g_hash_table_new(tcp_segment_hash, + tcp_segment_equal); tcp_segment_key_chunk = g_mem_chunk_new("tcp_segment_key_chunk", sizeof(tcp_segment_key), -- cgit v1.2.3