aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-08-12 23:00:01 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2005-08-12 23:00:01 +0000
commit4a3a614fd94e31bd6af8e7ee9f71c062e6ef13c5 (patch)
tree91782a39d9329d235d0be3510f2b2e4b7385521a /epan/dissectors
parent8692baec8cfe1321ec09f4e583797866d0b1e698 (diff)
more gmemchunk -> se_alloc() improvements
svn path=/trunk/; revision=15321
Diffstat (limited to 'epan/dissectors')
-rw-r--r--epan/dissectors/packet-fcfcs.c22
-rw-r--r--epan/dissectors/packet-fcfzs.c22
-rw-r--r--epan/dissectors/packet-fcp.c25
-rw-r--r--epan/dissectors/packet-giop.c52
-rw-r--r--epan/dissectors/packet-ipx.c40
-rw-r--r--epan/dissectors/packet-iscsi.c26
6 files changed, 24 insertions, 163 deletions
diff --git a/epan/dissectors/packet-fcfcs.c b/epan/dissectors/packet-fcfcs.c
index a974bf12e8..fc86218d8d 100644
--- a/epan/dissectors/packet-fcfcs.c
+++ b/epan/dissectors/packet-fcfcs.c
@@ -42,6 +42,7 @@
#include <glib.h>
#include <epan/packet.h>
+#include <epan/emem.h>
#include <epan/conversation.h>
#include "etypes.h"
#include "packet-fc.h"
@@ -99,9 +100,6 @@ typedef struct _fcfcs_conv_data {
} fcfcs_conv_data_t;
GHashTable *fcfcs_req_hash = NULL;
-GMemChunk *fcfcs_req_keys = NULL;
-GMemChunk *fcfcs_req_vals = NULL;
-guint32 fcfcs_init_count = 25;
static dissector_handle_t data_handle;
@@ -134,24 +132,10 @@ fcfcs_hash (gconstpointer v)
static void
fcfcs_init_protocol(void)
{
- if (fcfcs_req_keys)
- g_mem_chunk_destroy (fcfcs_req_keys);
- if (fcfcs_req_vals)
- g_mem_chunk_destroy (fcfcs_req_vals);
if (fcfcs_req_hash)
g_hash_table_destroy (fcfcs_req_hash);
fcfcs_req_hash = g_hash_table_new(fcfcs_hash, fcfcs_equal);
- fcfcs_req_keys = g_mem_chunk_new ("fcfcs_req_keys",
- sizeof(fcfcs_conv_key_t),
- fcfcs_init_count *
- sizeof(fcfcs_conv_key_t),
- G_ALLOC_AND_FREE);
- fcfcs_req_vals = g_mem_chunk_new ("fcfcs_req_vals",
- sizeof(fcfcs_conv_data_t),
- fcfcs_init_count *
- sizeof(fcfcs_conv_data_t),
- G_ALLOC_AND_FREE);
}
/* Code to actually dissect the packets */
@@ -855,10 +839,10 @@ dissect_fcfcs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
cdata->opcode = opcode;
}
else {
- req_key = g_mem_chunk_alloc (fcfcs_req_keys);
+ req_key = se_alloc (sizeof(fcfcs_conv_key_t));
req_key->conv_idx = conversation->index;
- cdata = g_mem_chunk_alloc (fcfcs_req_vals);
+ cdata = se_alloc (sizeof(fcfcs_conv_data_t));
cdata->opcode = opcode;
g_hash_table_insert (fcfcs_req_hash, req_key, cdata);
diff --git a/epan/dissectors/packet-fcfzs.c b/epan/dissectors/packet-fcfzs.c
index b1284726f2..dbf5e8cc0a 100644
--- a/epan/dissectors/packet-fcfzs.c
+++ b/epan/dissectors/packet-fcfzs.c
@@ -48,6 +48,7 @@
#include <glib.h>
#include <epan/packet.h>
+#include <epan/emem.h>
#include <epan/conversation.h>
#include "etypes.h"
#include "packet-fc.h"
@@ -92,9 +93,6 @@ typedef struct _fcfzs_conv_data {
} fcfzs_conv_data_t;
GHashTable *fcfzs_req_hash = NULL;
-GMemChunk *fcfzs_req_keys = NULL;
-GMemChunk *fcfzs_req_vals = NULL;
-guint32 fcfzs_init_count = 25;
static dissector_handle_t data_handle;
@@ -127,24 +125,10 @@ fcfzs_hash (gconstpointer v)
static void
fcfzs_init_protocol(void)
{
- if (fcfzs_req_keys)
- g_mem_chunk_destroy (fcfzs_req_keys);
- if (fcfzs_req_vals)
- g_mem_chunk_destroy (fcfzs_req_vals);
if (fcfzs_req_hash)
g_hash_table_destroy (fcfzs_req_hash);
fcfzs_req_hash = g_hash_table_new (fcfzs_hash, fcfzs_equal);
- fcfzs_req_keys = g_mem_chunk_new ("fcfzs_req_keys",
- sizeof(fcfzs_conv_key_t),
- fcfzs_init_count *
- sizeof(fcfzs_conv_key_t),
- G_ALLOC_AND_FREE);
- fcfzs_req_vals = g_mem_chunk_new ("fcfzs_req_vals",
- sizeof(fcfzs_conv_data_t),
- fcfzs_init_count *
- sizeof(fcfzs_conv_data_t),
- G_ALLOC_AND_FREE);
}
/* Code to actually dissect the packets */
@@ -681,10 +665,10 @@ dissect_fcfzs (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
cdata->opcode = opcode;
}
else {
- req_key = g_mem_chunk_alloc (fcfzs_req_keys);
+ req_key = se_alloc (sizeof(fcfzs_conv_key_t));
req_key->conv_idx = conversation->index;
- cdata = g_mem_chunk_alloc (fcfzs_req_vals);
+ cdata = se_alloc (sizeof(fcfzs_conv_data_t));
cdata->opcode = opcode;
g_hash_table_insert (fcfzs_req_hash, req_key, cdata);
diff --git a/epan/dissectors/packet-fcp.c b/epan/dissectors/packet-fcp.c
index 47b463347b..f84a1474b3 100644
--- a/epan/dissectors/packet-fcp.c
+++ b/epan/dissectors/packet-fcp.c
@@ -42,6 +42,7 @@
#include <glib.h>
#include <epan/prefs.h>
+#include <epan/emem.h>
#include <epan/packet.h>
#include <epan/conversation.h>
#include "etypes.h"
@@ -88,9 +89,6 @@ typedef struct _fcp_conv_data {
} fcp_conv_data_t;
GHashTable *fcp_req_hash = NULL;
-GMemChunk *fcp_req_keys = NULL;
-GMemChunk *fcp_req_vals = NULL;
-guint32 fcp_init_count = 25;
/*
* Hash Functions
@@ -121,22 +119,10 @@ fcp_hash (gconstpointer v)
static void
fcp_init_protocol(void)
{
- if (fcp_req_keys)
- g_mem_chunk_destroy(fcp_req_keys);
- if (fcp_req_vals)
- g_mem_chunk_destroy(fcp_req_vals);
if (fcp_req_hash)
g_hash_table_destroy(fcp_req_hash);
fcp_req_hash = g_hash_table_new(fcp_hash, fcp_equal);
- fcp_req_keys = g_mem_chunk_new("fcp_req_keys",
- sizeof(fcp_conv_key_t),
- fcp_init_count * sizeof(fcp_conv_key_t),
- G_ALLOC_AND_FREE);
- fcp_req_vals = g_mem_chunk_new("fcp_req_vals",
- sizeof(fcp_conv_data_t),
- fcp_init_count * sizeof(fcp_conv_data_t),
- G_ALLOC_AND_FREE);
}
static gchar *
@@ -294,10 +280,10 @@ dissect_fcp_cmnd (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
cdata->abs_secs = pinfo->fd->abs_secs;
}
else {
- req_key = g_mem_chunk_alloc (fcp_req_keys);
+ req_key = se_alloc (sizeof(fcp_conv_key_t));
req_key->conv_idx = conversation->index;
- cdata = g_mem_chunk_alloc (fcp_req_vals);
+ cdata = se_alloc (sizeof(fcp_conv_data_t));
cdata->fcp_dl = tvb_get_ntohl (tvb, offset+12+16+add_len);
cdata->abs_usecs = pinfo->fd->abs_usecs;
cdata->abs_secs = pinfo->fd->abs_secs;
@@ -498,7 +484,6 @@ dissect_fcp_rsp (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/*
* XXX - this isn't done if an exception is thrown.
*/
- g_mem_chunk_free (fcp_req_vals, cdata);
g_hash_table_remove (fcp_req_hash, &ckey);
}
}
@@ -535,10 +520,10 @@ dissect_fcp_xfer_rdy (tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
cdata->fcp_dl = tvb_get_ntohl (tvb, offset+4);
}
else {
- req_key = g_mem_chunk_alloc (fcp_req_keys);
+ req_key = se_alloc (sizeof(fcp_conv_key_t));
req_key->conv_idx = conversation->index;
- cdata = g_mem_chunk_alloc (fcp_req_vals);
+ cdata = se_alloc (sizeof(fcp_conv_data_t));
cdata->fcp_dl = tvb_get_ntohl (tvb, offset+4);
cdata->fcp_lun = -1;
diff --git a/epan/dissectors/packet-giop.c b/epan/dissectors/packet-giop.c
index 5c0abe2850..fb68597b8f 100644
--- a/epan/dissectors/packet-giop.c
+++ b/epan/dissectors/packet-giop.c
@@ -296,6 +296,7 @@
#include <epan/packet.h>
#include "packet-giop.h"
+#include <epan/emem.h>
/*
* Set to 1 for DEBUG output - TODO make this a runtime option
@@ -648,9 +649,6 @@ typedef struct comp_req_list_entry comp_req_list_entry_t;
* Maps reply FN to request MFN
*/
-static int complete_reply_hash_count = 1000; /* storage size for our permanent data */
- /* ie: 1000 entries -- needs tweaking -- FS */
-
struct complete_reply_hash_key {
guint32 fn; /* reply frame number */
};
@@ -660,9 +658,6 @@ struct complete_reply_hash_val {
};
GHashTable *giop_complete_reply_hash = NULL; /* hash */
-GMemChunk *giop_complete_reply_keys = NULL; /* key storage */
-GMemChunk *giop_complete_reply_vals = NULL; /* val storage */
-
/*
* DATA - Module Hash stuff to store data from register_giop_user_module
@@ -777,9 +772,6 @@ typedef enum collection_data collection_data_t;
-static int giop_objkey_init_count = 100; /* storage size for our permanent data */
- /* ie: 100 entries -- needs tweaking -- FS */
-
struct giop_object_key {
guint8 *objkey; /* ptr to object key */
guint32 objkey_len; /* length */
@@ -791,9 +783,6 @@ struct giop_object_val {
};
GHashTable *giop_objkey_hash = NULL; /* hash */
-GMemChunk *giop_objkey_keys = NULL; /* key storage */
-GMemChunk *giop_objkey_vals = NULL; /* val storage */
-
/*
@@ -918,10 +907,10 @@ static void insert_in_complete_reply_hash(guint32 fn, guint32 mfn) {
return; /* FN collision */
}
- new_key = g_mem_chunk_alloc(giop_complete_reply_keys);
+ new_key = se_alloc(sizeof(struct complete_reply_hash_key));
new_key->fn = fn; /* save FN */
- val = g_mem_chunk_alloc(giop_complete_reply_vals);
+ val = se_alloc(sizeof(struct complete_reply_hash_val));
val->mfn = mfn; /* and MFN */
g_hash_table_insert(giop_complete_reply_hash, new_key, val);
@@ -1167,11 +1156,11 @@ static void insert_in_objkey_hash(GHashTable *hash, gchar *obj, guint32 len, gch
/* So, passed key should NOT exist in hash at this point.*/
- new_objkey_key = g_mem_chunk_alloc(giop_objkey_keys);
+ new_objkey_key = se_alloc(sizeof(struct giop_object_key));
new_objkey_key->objkey_len = len; /* save it */
new_objkey_key->objkey = (guint8 *) g_memdup(obj,len); /* copy from object and allocate ptr */
- objkey_val = g_mem_chunk_alloc(giop_objkey_vals);
+ objkey_val = se_alloc(sizeof(struct giop_object_val));
objkey_val->repo_id = g_strdup(repoid); /* duplicate and store Respository ID string */
objkey_val->src = src; /* where IOR came from */
@@ -1371,11 +1360,6 @@ static void giop_init(void) {
if (giop_objkey_hash)
g_hash_table_destroy(giop_objkey_hash);
- if (giop_objkey_keys)
- g_mem_chunk_destroy(giop_objkey_keys);
- if (giop_objkey_vals)
- g_mem_chunk_destroy(giop_objkey_vals);
-
/*
* Create hash, use my "equal" and "hash" functions.
@@ -1384,17 +1368,6 @@ static void giop_init(void) {
giop_objkey_hash = g_hash_table_new(giop_hash_objkey_hash, giop_hash_objkey_equal);
- giop_objkey_keys = g_mem_chunk_new("giop_objkey_keys",
- sizeof(struct giop_object_key),
- giop_objkey_init_count * sizeof(struct giop_object_key),
- G_ALLOC_AND_FREE);
-
- giop_objkey_vals = g_mem_chunk_new("giop_objkey_vals",
- sizeof(struct giop_object_val),
- giop_objkey_init_count * sizeof(struct giop_object_val),
- G_ALLOC_AND_FREE);
-
-
/*
* Create complete_reply_hash, use my "equal" and "hash" functions.
*
@@ -1402,10 +1375,6 @@ static void giop_init(void) {
if (giop_complete_reply_hash)
g_hash_table_destroy(giop_complete_reply_hash);
- if (giop_complete_reply_keys)
- g_mem_chunk_destroy(giop_complete_reply_keys);
- if (giop_complete_reply_vals)
- g_mem_chunk_destroy(giop_complete_reply_vals);
/*
@@ -1415,17 +1384,6 @@ static void giop_init(void) {
giop_complete_reply_hash = g_hash_table_new(complete_reply_hash_fn, complete_reply_equal_fn);
- giop_complete_reply_keys = g_mem_chunk_new("giop_complete_reply_keys",
- sizeof(struct complete_reply_hash_key),
- complete_reply_hash_count * sizeof(struct complete_reply_hash_key),
- G_ALLOC_AND_FREE);
-
- giop_complete_reply_vals = g_mem_chunk_new("giop_complete_reply_vals",
- sizeof(struct complete_reply_hash_val),
- complete_reply_hash_count * sizeof(struct complete_reply_hash_val),
- G_ALLOC_AND_FREE);
-
-
read_IOR_strings_from_file("IOR.txt", 600); /* testing */
diff --git a/epan/dissectors/packet-ipx.c b/epan/dissectors/packet-ipx.c
index 7b5c956513..2952e26850 100644
--- a/epan/dissectors/packet-ipx.c
+++ b/epan/dissectors/packet-ipx.c
@@ -44,11 +44,10 @@
#include "arcnet_pids.h"
#include <epan/conversation.h>
#include <epan/tap.h>
+#include <epan/emem.h>
static int ipx_tap = -1;
-#define SPX_PACKET_INIT_COUNT 200
-
/* The information in this module (IPX, SPX, NCP) comes from:
NetWare LAN Analysis, Second Edition
Laura A. Chappell and Dan E. Hakes
@@ -434,9 +433,6 @@ typedef struct {
} spx_rexmit_info;
static GHashTable *spx_hash = NULL;
-static GMemChunk *spx_hash_keys = NULL;
-static GMemChunk *spx_hash_values = NULL;
-static GMemChunk *spx_rexmit_infos = NULL;
/* Hash Functions */
static gint
@@ -468,26 +464,8 @@ spx_init_protocol(void)
if (spx_hash)
g_hash_table_destroy(spx_hash);
- if (spx_hash_keys)
- g_mem_chunk_destroy(spx_hash_keys);
- if (spx_hash_values)
- g_mem_chunk_destroy(spx_hash_values);
- if (spx_rexmit_infos)
- g_mem_chunk_destroy(spx_rexmit_infos);
spx_hash = g_hash_table_new(spx_hash_func, spx_equal);
- spx_hash_keys = g_mem_chunk_new("spx_hash_keys",
- sizeof(spx_hash_key),
- SPX_PACKET_INIT_COUNT * sizeof(spx_hash_key),
- G_ALLOC_ONLY);
- spx_hash_values = g_mem_chunk_new("spx_hash_values",
- sizeof(spx_hash_value),
- SPX_PACKET_INIT_COUNT * sizeof(spx_hash_value),
- G_ALLOC_ONLY);
- spx_rexmit_infos = g_mem_chunk_new("spx_rexmit_infos",
- sizeof(spx_rexmit_infos),
- SPX_PACKET_INIT_COUNT * sizeof(spx_rexmit_infos),
- G_ALLOC_ONLY);
}
/* After the sequential run, we don't need the spx hash table, or
@@ -502,16 +480,6 @@ spx_postseq_cleanup(void)
g_hash_table_destroy(spx_hash);
spx_hash = NULL;
}
- if (spx_hash_keys) {
- g_mem_chunk_destroy(spx_hash_keys);
- spx_hash_keys = NULL;
- }
- if (spx_hash_values) {
- g_mem_chunk_destroy(spx_hash_values);
- spx_hash_values = NULL;
- }
- /* Don't free the spx_rexmit_infos, as they're
- * needed during random-access processing of the proto_tree.*/
}
static spx_hash_value*
@@ -521,12 +489,12 @@ spx_hash_insert(conversation_t *conversation, guint32 spx_src, guint16 spx_seq)
spx_hash_value *value;
/* Now remember the packet, so we can find it if we later. */
- key = g_mem_chunk_alloc(spx_hash_keys);
+ key = se_alloc(sizeof(spx_hash_key));
key->conversation = conversation;
key->spx_src = spx_src;
key->spx_seq = spx_seq;
- value = g_mem_chunk_alloc(spx_hash_values);
+ value = se_alloc(sizeof(spx_hash_value));
value->spx_ack = 0;
value->spx_all = 0;
value->num = 0;
@@ -766,7 +734,7 @@ dissect_spx(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
* Found in the hash table. Mark this frame as
* a retransmission.
*/
- spx_rexmit_info = g_mem_chunk_alloc(spx_rexmit_infos);
+ spx_rexmit_info = se_alloc(sizeof(spx_rexmit_info));
spx_rexmit_info->num = pkt_value->num;
p_add_proto_data(pinfo->fd, proto_spx,
spx_rexmit_info);
diff --git a/epan/dissectors/packet-iscsi.c b/epan/dissectors/packet-iscsi.c
index 461b518fe5..d98ee25a18 100644
--- a/epan/dissectors/packet-iscsi.c
+++ b/epan/dissectors/packet-iscsi.c
@@ -47,6 +47,7 @@
#include <epan/conversation.h>
#include "packet-scsi.h"
#include "epan/nstime.h"
+#include <epan/emem.h>
/* the absolute values of these constants don't matter as long as
* latter revisions of the protocol are assigned a larger number */
@@ -213,7 +214,6 @@ typedef struct _iscsi_session_t {
guint32 header_digest;
} iscsi_session_t;
static GHashTable *iscsi_session_table = NULL;
-static GMemChunk *iscsi_sessions = NULL;
static gint
iscsi_session_equal(gconstpointer v, gconstpointer w)
{
@@ -641,8 +641,6 @@ typedef struct _iscsi_conv_data {
} iscsi_conv_data_t;
static GHashTable *iscsi_req_unmatched = NULL;
static GHashTable *iscsi_req_matched = NULL;
-static GMemChunk *iscsi_req_vals = NULL;
-static guint32 iscsi_init_count = 200;
static gint
iscsi_equal_unmatched(gconstpointer v, gconstpointer w)
@@ -706,14 +704,6 @@ iscsi_hash_matched (gconstpointer v)
static void
iscsi_init_protocol(void)
{
- if (iscsi_sessions) {
- g_mem_chunk_destroy(iscsi_sessions);
- iscsi_sessions=NULL;
- }
- if (iscsi_req_vals) {
- g_mem_chunk_destroy(iscsi_req_vals);
- iscsi_req_vals=NULL;
- }
if (iscsi_req_unmatched) {
g_hash_table_destroy(iscsi_req_unmatched);
iscsi_req_unmatched=NULL;
@@ -730,14 +720,6 @@ iscsi_init_protocol(void)
iscsi_req_unmatched = g_hash_table_new(iscsi_hash_unmatched, iscsi_equal_unmatched);
iscsi_req_matched = g_hash_table_new(iscsi_hash_matched, iscsi_equal_matched);
iscsi_session_table = g_hash_table_new(iscsi_session_hash, iscsi_session_equal);
- iscsi_req_vals = g_mem_chunk_new("iscsi_req_vals",
- sizeof(iscsi_conv_data_t),
- iscsi_init_count * sizeof(iscsi_conv_data_t),
- G_ALLOC_AND_FREE);
- iscsi_sessions = g_mem_chunk_new("iscsi_sessions",
- sizeof(iscsi_session_t),
- iscsi_init_count * sizeof(iscsi_session_t),
- G_ALLOC_AND_FREE);
}
static int
@@ -974,7 +956,7 @@ dissect_iscsi_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, guint off
}
/* add this new transaction to the unmatched table */
- cdata = g_mem_chunk_alloc (iscsi_req_vals);
+ cdata = se_alloc (sizeof(iscsi_conv_data_t));
cdata->conv_idx = iscsi_session->conv_idx;
cdata->itt = tvb_get_ntohl (tvb, offset+16);
cdata->lun=lun;
@@ -1891,7 +1873,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
conversation = conversation_new (pinfo->fd->num, &pinfo->src, &pinfo->dst,
pinfo->ptype, pinfo->srcport,
pinfo->destport, 0);
- iscsi_session=g_mem_chunk_alloc(iscsi_sessions);
+ iscsi_session=se_alloc(sizeof(iscsi_session_t));
iscsi_session->conv_idx=conversation->index;
iscsi_session->header_digest=ISCSI_HEADER_DIGEST_AUTO;
g_hash_table_insert(iscsi_session_table, iscsi_session, iscsi_session);
@@ -1902,7 +1884,7 @@ dissect_iscsi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, gboolean chec
/* this should never return NULL */
iscsi_session = (iscsi_session_t *)g_hash_table_lookup (iscsi_session_table, &key);
if(!iscsi_session){
- iscsi_session=g_mem_chunk_alloc(iscsi_sessions);
+ iscsi_session=se_alloc(sizeof(iscsi_session_t));
iscsi_session->conv_idx=conversation->index;
iscsi_session->header_digest=ISCSI_HEADER_DIGEST_AUTO;
g_hash_table_insert(iscsi_session_table, iscsi_session, iscsi_session);