stream: clean up reassembly table.
[metze/wireshark/wip.git] / epan / stream.c
index 29a6ebbccd8501d7d5f918940b88ef1011dcba51..3ac068c94741e62f359734b21145485973407ef4 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <glib.h>
 #include <epan/packet.h>
-#include <epan/emem.h>
 #include <epan/reassemble.h>
 #include <epan/stream.h>
 #include <epan/tvbuff.h>
@@ -93,7 +92,7 @@ static guint stream_hash_func(gconstpointer k)
     const stream_key_t *key = (const stream_key_t *)k;
 
     /* is_circuit is redundant to the circuit/conversation pointer */
-    return ((guint)(unsigned long)key->circ.circuit) ^ key->p2p_dir;
+    return (GPOINTER_TO_UINT(key->circ.circuit)) ^ key->p2p_dir;
 }
 
 /* compare func */
@@ -155,7 +154,7 @@ static stream_t *new_stream( stream_key_t *key )
 {
     stream_t *val;
 
-    val = se_new(stream_t);
+    val = wmem_new(wmem_file_scope(), stream_t);
     val -> key = key;
     val -> pdu_counter = 0;
     val -> current_pdu = NULL;
@@ -172,7 +171,7 @@ static stream_t *stream_hash_insert_circ( const struct circuit *circuit, int p2p
 {
     stream_key_t *key;
 
-    key = se_new(stream_key_t);
+    key = wmem_new(wmem_file_scope(), stream_key_t);
     key->is_circuit = TRUE;
     key->circ.circuit = circuit;
     key->p2p_dir = p2p_dir;
@@ -184,7 +183,7 @@ static stream_t *stream_hash_insert_conv( const struct conversation *conv, int p
 {
     stream_key_t *key;
 
-    key = se_new(stream_key_t);
+    key = wmem_new(wmem_file_scope(), stream_key_t);
     key->is_circuit = FALSE;
     key->circ.conv = conv;
     key->p2p_dir = p2p_dir;
@@ -215,7 +214,7 @@ static void stream_init_pdu_data(void)
 static stream_pdu_t *stream_new_pdu(stream_t *stream)
 {
     stream_pdu_t *pdu;
-    pdu = se_new(stream_pdu_t);
+    pdu = wmem_new(wmem_file_scope(), stream_pdu_t);
     pdu -> fd_head = NULL;
     pdu -> pdu_number = stream -> pdu_counter++;
     pdu -> id = pdu_counter++;
@@ -239,7 +238,7 @@ typedef struct fragment_key {
 static guint fragment_hash_func(gconstpointer k)
 {
     const fragment_key_t *key = (const fragment_key_t *)k;
-    return ((guint)(unsigned long)key->stream) + ((guint)key -> framenum) + ((guint)key->offset);
+    return (GPOINTER_TO_UINT(key->stream)) + ((guint)key -> framenum) + ((guint)key->offset);
 }
 
 /* compare func */
@@ -295,12 +294,12 @@ static stream_pdu_fragment_t *fragment_hash_insert( const stream_t *stream, guin
     fragment_key_t *key;
     stream_pdu_fragment_t *val;
 
-    key = se_new(fragment_key_t);
+    key = wmem_new(wmem_file_scope(), fragment_key_t);
     key->stream = stream;
     key->framenum = framenum;
     key->offset = offset;
 
-    val = se_new(stream_pdu_fragment_t);
+    val = wmem_new(wmem_file_scope(), stream_pdu_fragment_t);
     val->len = length;
     val->pdu = NULL;
     val->final_fragment = FALSE;
@@ -360,13 +359,14 @@ stream_t *find_stream_conv ( const struct conversation *conv, int p2p_dir )
 /* cleanup the stream routines */
 /* Note: stream_cleanup must only be called when seasonal memory
  *       is also freed since the hash tables countain pointers to
- *       se_alloc'd memory.
+ *       wmem_file_scoped memory.
  */
 void stream_cleanup( void )
 {
     cleanup_stream_hash();
     cleanup_fragment_hash();
     stream_cleanup_pdu_data();
+    reassembly_table_destroy(&stream_reassembly_table);
 }
 
 /* initialise the stream routines */
@@ -476,3 +476,16 @@ guint32 stream_get_pdu_no( const stream_pdu_fragment_t *frag)
     DISSECTOR_ASSERT( frag );
     return frag->pdu->pdu_number;
 }
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */