diff options
author | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-12-22 09:01:12 +0000 |
---|---|---|
committer | Ronnie Sahlberg <ronnie_sahlberg@ozemail.com.au> | 2006-12-22 09:01:12 +0000 |
commit | 8fc740a53eff66f97ce426a529baa5af6c70806b (patch) | |
tree | e1c300a4a239db44fec60c55c40326bdd868cfe0 /epan/ftypes | |
parent | 8433f6d5895f6c47231c1e38ee65cbd07bc7a646 (diff) |
hmm
best to revert this for a while.
revert all changes from previous patch.
svn path=/trunk/; revision=20195
Diffstat (limited to 'epan/ftypes')
-rw-r--r-- | epan/ftypes/ftype-ipv4.c | 1 | ||||
-rw-r--r-- | epan/ftypes/ftype-string.c | 1 | ||||
-rw-r--r-- | epan/ftypes/ftypes.c | 5 | ||||
-rw-r--r-- | epan/ftypes/ftypes.h | 25 |
4 files changed, 30 insertions, 2 deletions
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c index 6a17e528fa..045c9fbf10 100644 --- a/epan/ftypes/ftype-ipv4.c +++ b/epan/ftypes/ftype-ipv4.c @@ -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", diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c index b156cb1d60..b24086363c 100644 --- a/epan/ftypes/ftype-string.c +++ b/epan/ftypes/ftype-string.c @@ -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 { diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c index a096f7a9d2..a2305f97f9 100644 --- a/epan/ftypes/ftypes.c +++ b/epan/ftypes/ftypes.c @@ -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; } diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h index 145c3bc272..6e42655693 100644 --- a/epan/ftypes/ftypes.h +++ b/epan/ftypes/ftypes.h @@ -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); |