aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2006-12-22 08:35:43 +0000
committersahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7>2006-12-22 08:35:43 +0000
commit118f0d31400cb2e0dd6a6d1c852f65b806db42f7 (patch)
tree760fcd65bf9721b8a488ce4f1b974347949acdee
parentf7be12c3be8044b57f2ff58bbc8ad193433f5b02 (diff)
change some slab allocated memory into ep/emem allocated structures instead.
this primarily removes code and simplifies (==eliminates) the need to track the data that is allocated and should potentially be slightly faster than a slab allocator. however these functions are called A LOT so there might be a performance hit when using emem with full debugging canary values and all the bells and whistles activated. this change also makes any future attempt to parallellize dissection of frames easier if we just make the ep allocator allocate from a threads specific ep pool. (something we would have to do anyway to make ep allocations multithreaded) this works in all my tests so far but needs more test coverage. git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@20194 f5534014-38df-0310-8fa8-9805f1628bb7
-rw-r--r--epan/dfilter/dfvm.c1
-rw-r--r--epan/ftypes/ftype-ipv4.c1
-rw-r--r--epan/ftypes/ftype-string.c1
-rw-r--r--epan/ftypes/ftypes.c5
-rw-r--r--epan/ftypes/ftypes.h25
-rw-r--r--epan/libwireshark.def1
-rw-r--r--epan/proto.c71
-rw-r--r--gtk/dfilter_expr_dlg.c1
8 files changed, 6 insertions, 100 deletions
diff --git a/epan/dfilter/dfvm.c b/epan/dfilter/dfvm.c
index 9d368abb18..d3db1121ac 100644
--- a/epan/dfilter/dfvm.c
+++ b/epan/dfilter/dfvm.c
@@ -44,7 +44,6 @@ dfvm_value_free(dfvm_value_t *v)
{
switch (v->type) {
case FVALUE:
- FVALUE_FREE(v->value.fvalue);
break;
case DRANGE:
drange_free(v->value.drange);
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c
index 045c9fbf10..6a17e528fa 100644
--- a/epan/ftypes/ftype-ipv4.c
+++ b/epan/ftypes/ftype-ipv4.c
@@ -105,7 +105,6 @@ val_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFu
return FALSE;
}
nmask_bits = fvalue_get_integer(nmask_fvalue);
- FVALUE_FREE(nmask_fvalue);
if (nmask_bits > 32) {
logfunc("Netmask bits in a CIDR IPv4 address should be <= 32, not %u",
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c
index b24086363c..b156cb1d60 100644
--- a/epan/ftypes/ftype-string.c
+++ b/epan/ftypes/ftype-string.c
@@ -178,7 +178,6 @@ val_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFu
memcpy(fv->value.string, fv_bytes->value.bytes->data, num_bytes);
fv->value.string[num_bytes] = '\0';
- FVALUE_FREE(fv_bytes);
return TRUE;
}
else {
diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c
index a2305f97f9..a096f7a9d2 100644
--- a/epan/ftypes/ftypes.c
+++ b/epan/ftypes/ftypes.c
@@ -27,6 +27,7 @@
#include <ftypes-int.h>
#include <glib.h>
#include "../slab.h"
+#include "../emem.h"
#include "ftypes.h"
@@ -203,7 +204,7 @@ fvalue_new(ftenum_t ftype)
ftype_t *ft;
FvalueNewFunc new_value;
- SLAB_ALLOC(fv, fvalue_t);
+ fv=ep_alloc(sizeof(fvalue_t));
FTYPE_LOOKUP(ftype, ft);
fv->ftype = ft;
@@ -246,7 +247,6 @@ fvalue_from_unparsed(ftenum_t ftype, char *s, gboolean allow_partial_value, LogF
logfunc("\"%s\" cannot be converted to %s.",
s, ftype_pretty_name(ftype));
}
- FVALUE_FREE(fv);
return NULL;
}
@@ -265,7 +265,6 @@ fvalue_from_string(ftenum_t ftype, char *s, LogFunc logfunc)
logfunc("\"%s\" cannot be converted to %s.",
s, ftype_pretty_name(ftype));
}
- FVALUE_FREE(fv);
return NULL;
}
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index 6e42655693..145c3bc272 100644
--- a/epan/ftypes/ftypes.h
+++ b/epan/ftypes/ftypes.h
@@ -241,31 +241,6 @@ void
fvalue_init(fvalue_t *fv, ftenum_t ftype);
-/* Define type needed for the fvalue_t free list. */
-SLAB_ITEM_TYPE_DEFINE(fvalue_t)
-
-/* Free all memory used by an fvalue_t. With MSVC and a
- * libwireshark.dll, we need a special declaration.
- */
-WS_VAR_IMPORT SLAB_FREE_LIST_DECLARE(fvalue_t)
-
-
-#define FVALUE_CLEANUP(fv) \
- { \
- register FvalueFreeFunc free_value; \
- free_value = (fv)->ftype->free_value; \
- if (free_value) { \
- free_value((fv)); \
- } \
- }
-
-#define FVALUE_FREE(fv) \
- { \
- FVALUE_CLEANUP(fv) \
- SLAB_FREE(fv, fvalue_t); \
- }
-
-
fvalue_t*
fvalue_from_unparsed(ftenum_t ftype, char *s, gboolean allow_partial_value, LogFunc logfunc);
diff --git a/epan/libwireshark.def b/epan/libwireshark.def
index 1d0f340c91..62b31da062 100644
--- a/epan/libwireshark.def
+++ b/epan/libwireshark.def
@@ -322,7 +322,6 @@ ftype_can_matches
ftype_can_ne
ftype_can_slice
ftype_pretty_name
-fvalue_t_free_list DATA
fvalue_from_unparsed
fvalue_get
fvalue_get_floating
diff --git a/epan/proto.c b/epan/proto.c
index 1cbcb19aac..f4bc266acb 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -203,17 +203,6 @@ static GList *protocols = NULL;
* dissectors register their data */
static GMemChunk *gmc_hfinfo = NULL;
-/* Contains information about a field when a dissector calls
- * proto_tree_add_item. */
-SLAB_ITEM_TYPE_DEFINE(field_info)
-static SLAB_FREE_LIST_DEFINE(field_info)
-static field_info *field_info_tmp=NULL;
-#define FIELD_INFO_NEW(fi) \
- SLAB_ALLOC(fi, field_info)
-#define FIELD_INFO_FREE(fi) \
- SLAB_FREE(fi, field_info)
-
-
/* Contains the space for proto_nodes. */
SLAB_ITEM_TYPE_DEFINE(proto_node)
@@ -229,15 +218,6 @@ static SLAB_FREE_LIST_DEFINE(proto_node)
-/* String space for protocol and field items for the GUI */
-SLAB_ITEM_TYPE_DEFINE(item_label_t)
-static SLAB_FREE_LIST_DEFINE(item_label_t)
-#define ITEM_LABEL_NEW(il) \
- SLAB_ALLOC(il, item_label_t)
-#define ITEM_LABEL_FREE(il) \
- SLAB_FREE(il, item_label_t)
-
-
#define PROTO_REGISTRAR_GET_NTH(hfindex, hfinfo) \
DISSECTOR_ASSERT((guint)hfindex < gpa_hfinfo.len); \
hfinfo=gpa_hfinfo.hfi[hfindex];
@@ -516,13 +496,6 @@ free_node_tree_data(tree_data_t *tree_data)
g_free(tree_data);
}
-#define FREE_NODE_FIELD_INFO(finfo) \
- if(finfo->rep){ \
- ITEM_LABEL_FREE(finfo->rep); \
- } \
- FVALUE_CLEANUP(&finfo->value); \
- FIELD_INFO_FREE(finfo);
-
static gboolean
proto_tree_free_node(proto_node *node, gpointer data _U_)
{
@@ -533,11 +506,6 @@ proto_tree_free_node(proto_node *node, gpointer data _U_)
* There is no field_info to destroy. */
free_node_tree_data(PTREE_DATA(node));
}
- else {
- /* This is a child node. Don't free the per-tree data, but
- * do free the field_info data. */
- FREE_NODE_FIELD_INFO(finfo);
- }
/* Free the proto_node. */
PROTO_NODE_FREE(node);
@@ -805,28 +773,6 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree, int hfindex,
GHashTable *hash;
GPtrArray *ptrs;
- /* there is a possibility here that we might raise an exception
- * and thus would lose track of the field_info.
- * store it in a temp so that if we come here again we can reclaim
- * the field_info without leaking memory.
- */
- /* XXX this only keeps track of one field_info struct,
- if we ever go multithreaded for calls to this function
- we have to change this code to use per thread variable.
- */
- if(field_info_tmp){
- /* oops, last one we got must have been lost due
- * to an exception.
- * good thing we saved it, now we can reverse the
- * memory leak and reclaim it.
- */
- SLAB_FREE(field_info_tmp, field_info);
- }
- /* we might throw an exception, keep track of this one
- * across the "dangerous" section below.
- */
- field_info_tmp=new_fi;
-
switch(new_fi->hfinfo->type) {
case FT_NONE:
/* no value to set for FT_NONE */
@@ -1025,11 +971,6 @@ proto_tree_new_item(field_info *new_fi, proto_tree *tree, int hfindex,
* raised by a tvbuff access method doesn't leave junk in the proto_tree. */
pi = proto_tree_add_node(tree, new_fi);
- /* we did not raise an exception so we dont have to remember this
- * field_info struct any more.
- */
- field_info_tmp=NULL;
-
/* If the proto_tree wants to keep a record of this finfo
* for quick lookup, then record it. */
if (new_fi->hfinfo->ref_count) {
@@ -2876,7 +2817,7 @@ new_field_info(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb,
{
field_info *fi;
- FIELD_INFO_NEW(fi);
+ fi=ep_alloc(sizeof(field_info));
fi->hfinfo = hfinfo;
fi->start = start;
@@ -2918,7 +2859,7 @@ proto_tree_set_representation_value(proto_item *pi, const char *format, va_list
field_info *fi = PITEM_FINFO(pi);
if (!PROTO_ITEM_IS_HIDDEN(pi)) {
- ITEM_LABEL_NEW(fi->rep);
+ fi->rep=ep_alloc(sizeof(item_label_t));
replen = 0;
ret = g_snprintf(fi->rep->representation, ITEM_LABEL_LENGTH,
"%s: ", fi->hfinfo->name);
@@ -2945,7 +2886,7 @@ proto_tree_set_representation(proto_item *pi, const char *format, va_list ap)
field_info *fi = PITEM_FINFO(pi);
if (!PROTO_ITEM_IS_HIDDEN(pi)) {
- ITEM_LABEL_NEW(fi->rep);
+ fi->rep=ep_alloc(sizeof(item_label_t));
ret = g_vsnprintf(fi->rep->representation, ITEM_LABEL_LENGTH, format, ap);
if ((ret == -1) || (ret >= ITEM_LABEL_LENGTH))
fi->rep->representation[ITEM_LABEL_LENGTH - 1] = '\0';
@@ -2965,10 +2906,6 @@ proto_item_set_text(proto_item *pi, const char *format, ...)
fi = PITEM_FINFO(pi);
- if(fi->rep){
- ITEM_LABEL_FREE(fi->rep);
- }
-
va_start(ap, format);
proto_tree_set_representation(pi, format, ap);
va_end(ap);
@@ -2997,7 +2934,7 @@ proto_item_append_text(proto_item *pi, const char *format, ...)
* generate the default representation.
*/
if (fi->rep == NULL) {
- ITEM_LABEL_NEW(fi->rep);
+ fi->rep=ep_alloc(sizeof(item_label_t));
proto_item_fill_label(fi, fi->rep->representation);
}
diff --git a/gtk/dfilter_expr_dlg.c b/gtk/dfilter_expr_dlg.c
index 1eccd111f7..875944a7dc 100644
--- a/gtk/dfilter_expr_dlg.c
+++ b/gtk/dfilter_expr_dlg.c
@@ -920,7 +920,6 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
g_free(value_str);
return;
}
- FVALUE_FREE(fvalue);
} else {
value_str = NULL;
stripped_value_str = NULL;