best to revert this for a while.



revert all changes from previous patch.



svn path=/trunk/; revision=20195
This commit is contained in:
Ronnie Sahlberg 2006-12-22 09:01:12 +00:00
parent 8433f6d589
commit 8fc740a53e
8 changed files with 100 additions and 6 deletions

View File

@ -44,6 +44,7 @@ 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);

View File

@ -105,6 +105,7 @@ 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",

View File

@ -178,6 +178,7 @@ 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 {

View File

@ -27,7 +27,6 @@
#include <ftypes-int.h>
#include <glib.h>
#include "../slab.h"
#include "../emem.h"
#include "ftypes.h"
@ -204,7 +203,7 @@ fvalue_new(ftenum_t ftype)
ftype_t *ft;
FvalueNewFunc new_value;
fv=ep_alloc(sizeof(fvalue_t));
SLAB_ALLOC(fv, fvalue_t);
FTYPE_LOOKUP(ftype, ft);
fv->ftype = ft;
@ -247,6 +246,7 @@ 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,6 +265,7 @@ 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;
}

View File

@ -241,6 +241,31 @@ 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);

View File

@ -322,6 +322,7 @@ 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

View File

@ -203,6 +203,17 @@ 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)
@ -218,6 +229,15 @@ 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];
@ -496,6 +516,13 @@ 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_)
{
@ -506,6 +533,11 @@ 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);
@ -773,6 +805,28 @@ 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 */
@ -971,6 +1025,11 @@ 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) {
@ -2817,7 +2876,7 @@ new_field_info(proto_tree *tree, header_field_info *hfinfo, tvbuff_t *tvb,
{
field_info *fi;
fi=ep_alloc(sizeof(field_info));
FIELD_INFO_NEW(fi);
fi->hfinfo = hfinfo;
fi->start = start;
@ -2859,7 +2918,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)) {
fi->rep=ep_alloc(sizeof(item_label_t));
ITEM_LABEL_NEW(fi->rep);
replen = 0;
ret = g_snprintf(fi->rep->representation, ITEM_LABEL_LENGTH,
"%s: ", fi->hfinfo->name);
@ -2886,7 +2945,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)) {
fi->rep=ep_alloc(sizeof(item_label_t));
ITEM_LABEL_NEW(fi->rep);
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';
@ -2906,6 +2965,10 @@ 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);
@ -2934,7 +2997,7 @@ proto_item_append_text(proto_item *pi, const char *format, ...)
* generate the default representation.
*/
if (fi->rep == NULL) {
fi->rep=ep_alloc(sizeof(item_label_t));
ITEM_LABEL_NEW(fi->rep);
proto_item_fill_label(fi, fi->rep->representation);
}

View File

@ -920,6 +920,7 @@ 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;