forked from osmocom/wireshark
fvalue_free() is one of the most called functions.
This function is also very small, so small that teh overhead for the actual function call and return is likely to be a significant part of its execution time. change it into a macro and make it thus slightly faster by eliminating the function call overhead. svn path=/trunk/; revision=9083
This commit is contained in:
parent
0bf28e51af
commit
4f84e65c50
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: dfvm.c,v 1.10 2003/08/27 15:23:03 gram Exp $
|
||||
* $Id: dfvm.c,v 1.11 2003/11/25 13:20:35 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -45,7 +45,7 @@ dfvm_value_free(dfvm_value_t *v)
|
|||
{
|
||||
switch (v->type) {
|
||||
case FVALUE:
|
||||
fvalue_free(v->value.fvalue);
|
||||
FVALUE_FREE(v->value.fvalue);
|
||||
break;
|
||||
case DRANGE:
|
||||
drange_free(v->value.drange);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: ftype-ipv4.c,v 1.13 2003/08/27 15:23:07 gram Exp $
|
||||
* $Id: ftype-ipv4.c,v 1.14 2003/11/25 13:20:35 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -105,7 +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);
|
||||
FVALUE_FREE(nmask_fvalue);
|
||||
|
||||
if (nmask_bits > 32) {
|
||||
logfunc("Netmask bits in a CIDR IPv4 address should be <= 32, not %u",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: ftype-string.c,v 1.14 2003/10/29 23:48:14 guy Exp $
|
||||
* $Id: ftype-string.c,v 1.15 2003/11/25 13:20:36 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -144,7 +144,7 @@ val_from_unparsed(fvalue_t *fv, char *s, gboolean allow_partial_value _U_, LogFu
|
|||
memcpy(fv->value.string, fv->value.bytes->data, num_bytes);
|
||||
fv->value.string[num_bytes] = '\0';
|
||||
|
||||
fvalue_free(fv_bytes);
|
||||
FVALUE_FREE(fv_bytes);
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: ftypes-int.h,v 1.10 2003/08/27 15:23:08 gram Exp $
|
||||
* $Id: ftypes-int.h,v 1.11 2003/11/25 13:20:36 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -26,61 +26,6 @@
|
|||
#include <epan/packet.h>
|
||||
#include "ftypes.h"
|
||||
|
||||
typedef void (*FvalueNewFunc)(fvalue_t*);
|
||||
typedef void (*FvalueFreeFunc)(fvalue_t*);
|
||||
|
||||
typedef gboolean (*FvalueFromUnparsed)(fvalue_t*, char*, gboolean, LogFunc);
|
||||
typedef gboolean (*FvalueFromString)(fvalue_t*, char*, LogFunc);
|
||||
typedef void (*FvalueToStringRepr)(fvalue_t*, ftrepr_t, char*);
|
||||
typedef int (*FvalueStringReprLen)(fvalue_t*, ftrepr_t);
|
||||
|
||||
typedef void (*FvalueSetFunc)(fvalue_t*, gpointer, gboolean);
|
||||
typedef void (*FvalueSetIntegerFunc)(fvalue_t*, guint32);
|
||||
typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble);
|
||||
|
||||
typedef gpointer (*FvalueGetFunc)(fvalue_t*);
|
||||
typedef guint32 (*FvalueGetIntegerFunc)(fvalue_t*);
|
||||
typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
|
||||
|
||||
typedef gboolean (*FvalueCmp)(fvalue_t*, fvalue_t*);
|
||||
|
||||
typedef guint (*FvalueLen)(fvalue_t*);
|
||||
typedef void (*FvalueSlice)(fvalue_t*, GByteArray *, guint offset, guint length);
|
||||
|
||||
struct _ftype_t {
|
||||
const char *name;
|
||||
const char *pretty_name;
|
||||
int wire_size;
|
||||
FvalueNewFunc new_value;
|
||||
FvalueFreeFunc free_value;
|
||||
FvalueFromUnparsed val_from_unparsed;
|
||||
FvalueFromString val_from_string;
|
||||
FvalueToStringRepr val_to_string_repr;
|
||||
FvalueStringReprLen len_string_repr;
|
||||
|
||||
/* could be union */
|
||||
FvalueSetFunc set_value;
|
||||
FvalueSetIntegerFunc set_value_integer;
|
||||
FvalueSetFloatingFunc set_value_floating;
|
||||
|
||||
/* could be union */
|
||||
FvalueGetFunc get_value;
|
||||
FvalueGetIntegerFunc get_value_integer;
|
||||
FvalueGetFloatingFunc get_value_floating;
|
||||
|
||||
FvalueCmp cmp_eq;
|
||||
FvalueCmp cmp_ne;
|
||||
FvalueCmp cmp_gt;
|
||||
FvalueCmp cmp_ge;
|
||||
FvalueCmp cmp_lt;
|
||||
FvalueCmp cmp_le;
|
||||
FvalueCmp cmp_contains;
|
||||
|
||||
FvalueLen len;
|
||||
FvalueSlice slice;
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
ftype_register(enum ftenum ftype, ftype_t *ft);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* $Id: ftypes.c,v 1.12 2003/11/25 08:50:37 sahlberg Exp $
|
||||
* $Id: ftypes.c,v 1.13 2003/11/25 13:20:36 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -31,7 +31,7 @@
|
|||
static ftype_t* type_list[FT_NUM_TYPES];
|
||||
|
||||
/* Space for quickly allocating/de-allocating fvalue_t's */
|
||||
static fvalue_t *fvalue_free_list=NULL;
|
||||
fvalue_t *fvalue_free_list=NULL;
|
||||
|
||||
/* These are the ftype registration functions that need to be called.
|
||||
* This list and the initialization function could be produced
|
||||
|
@ -230,21 +230,6 @@ fvalue_new(ftenum_t ftype)
|
|||
return fv;
|
||||
}
|
||||
|
||||
/* Free all memory used by an fvalue_t */
|
||||
void
|
||||
fvalue_free(fvalue_t *fv)
|
||||
{
|
||||
FvalueFreeFunc free_value;
|
||||
|
||||
free_value = fv->ptr_u.ftype->free_value;
|
||||
if (free_value) {
|
||||
free_value(fv);
|
||||
}
|
||||
|
||||
fv->ptr_u.next=fvalue_free_list; \
|
||||
fvalue_free_list=fv;
|
||||
}
|
||||
|
||||
fvalue_t*
|
||||
fvalue_from_unparsed(ftenum_t ftype, char *s, gboolean allow_partial_value, LogFunc logfunc)
|
||||
{
|
||||
|
@ -260,7 +245,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);
|
||||
FVALUE_FREE(fv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -279,7 +264,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);
|
||||
FVALUE_FREE(fv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* ftypes.h
|
||||
* Definitions for field types
|
||||
*
|
||||
* $Id: ftypes.h,v 1.20 2003/11/25 08:50:38 sahlberg Exp $
|
||||
* $Id: ftypes.h,v 1.21 2003/11/25 13:20:36 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -154,13 +154,79 @@ typedef struct _fvalue_t {
|
|||
|
||||
} fvalue_t;
|
||||
|
||||
typedef void (*FvalueNewFunc)(fvalue_t*);
|
||||
typedef void (*FvalueFreeFunc)(fvalue_t*);
|
||||
typedef void (*LogFunc)(char*,...);
|
||||
|
||||
typedef gboolean (*FvalueFromUnparsed)(fvalue_t*, char*, gboolean, LogFunc);
|
||||
typedef gboolean (*FvalueFromString)(fvalue_t*, char*, LogFunc);
|
||||
typedef void (*FvalueToStringRepr)(fvalue_t*, ftrepr_t, char*);
|
||||
typedef int (*FvalueStringReprLen)(fvalue_t*, ftrepr_t);
|
||||
|
||||
typedef void (*FvalueSetFunc)(fvalue_t*, gpointer, gboolean);
|
||||
typedef void (*FvalueSetIntegerFunc)(fvalue_t*, guint32);
|
||||
typedef void (*FvalueSetFloatingFunc)(fvalue_t*, gdouble);
|
||||
|
||||
typedef gpointer (*FvalueGetFunc)(fvalue_t*);
|
||||
typedef guint32 (*FvalueGetIntegerFunc)(fvalue_t*);
|
||||
typedef double (*FvalueGetFloatingFunc)(fvalue_t*);
|
||||
|
||||
typedef gboolean (*FvalueCmp)(fvalue_t*, fvalue_t*);
|
||||
|
||||
typedef guint (*FvalueLen)(fvalue_t*);
|
||||
typedef void (*FvalueSlice)(fvalue_t*, GByteArray *, guint offset, guint length);
|
||||
|
||||
struct _ftype_t {
|
||||
const char *name;
|
||||
const char *pretty_name;
|
||||
int wire_size;
|
||||
FvalueNewFunc new_value;
|
||||
FvalueFreeFunc free_value;
|
||||
FvalueFromUnparsed val_from_unparsed;
|
||||
FvalueFromString val_from_string;
|
||||
FvalueToStringRepr val_to_string_repr;
|
||||
FvalueStringReprLen len_string_repr;
|
||||
|
||||
/* could be union */
|
||||
FvalueSetFunc set_value;
|
||||
FvalueSetIntegerFunc set_value_integer;
|
||||
FvalueSetFloatingFunc set_value_floating;
|
||||
|
||||
/* could be union */
|
||||
FvalueGetFunc get_value;
|
||||
FvalueGetIntegerFunc get_value_integer;
|
||||
FvalueGetFloatingFunc get_value_floating;
|
||||
|
||||
FvalueCmp cmp_eq;
|
||||
FvalueCmp cmp_ne;
|
||||
FvalueCmp cmp_gt;
|
||||
FvalueCmp cmp_ge;
|
||||
FvalueCmp cmp_lt;
|
||||
FvalueCmp cmp_le;
|
||||
FvalueCmp cmp_contains;
|
||||
|
||||
FvalueLen len;
|
||||
FvalueSlice slice;
|
||||
};
|
||||
|
||||
|
||||
fvalue_t*
|
||||
fvalue_new(ftenum_t ftype);
|
||||
|
||||
void
|
||||
fvalue_free(fvalue_t *fv);
|
||||
|
||||
typedef void (*LogFunc)(char*,...);
|
||||
/* Free all memory used by an fvalue_t */
|
||||
extern fvalue_t *fvalue_free_list;
|
||||
#define FVALUE_FREE(fv) \
|
||||
{ \
|
||||
FvalueFreeFunc free_value; \
|
||||
free_value = fv->ptr_u.ftype->free_value; \
|
||||
if (free_value) { \
|
||||
free_value(fv); \
|
||||
} \
|
||||
fv->ptr_u.next=fvalue_free_list; \
|
||||
fvalue_free_list=fv; \
|
||||
}
|
||||
|
||||
|
||||
fvalue_t*
|
||||
fvalue_from_unparsed(ftenum_t ftype, char *s, gboolean allow_partial_value, LogFunc logfunc);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* proto.c
|
||||
* Routines for protocol tree
|
||||
*
|
||||
* $Id: proto.c,v 1.108 2003/11/24 22:11:54 guy Exp $
|
||||
* $Id: proto.c,v 1.109 2003/11/25 13:20:34 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -349,7 +349,8 @@ free_node_field_info(field_info* finfo)
|
|||
if (finfo->representation) {
|
||||
g_mem_chunk_free(gmc_item_labels, finfo->representation);
|
||||
}
|
||||
fvalue_free(finfo->value);
|
||||
|
||||
FVALUE_FREE(finfo->value);
|
||||
free_field_info(finfo);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* Copyright 2000, Jeffrey C. Foster <jfoste@woodward.com> and
|
||||
* Guy Harris <guy@alum.mit.edu>
|
||||
*
|
||||
* $Id: dfilter_expr_dlg.c,v 1.43 2003/11/16 23:17:25 guy Exp $
|
||||
* $Id: dfilter_expr_dlg.c,v 1.44 2003/11/25 13:20:36 sahlberg Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@ethereal.com>
|
||||
|
@ -954,7 +954,7 @@ dfilter_expr_dlg_accept_cb(GtkWidget *w, gpointer filter_te_arg)
|
|||
g_free(value_str);
|
||||
return;
|
||||
}
|
||||
fvalue_free(fvalue);
|
||||
FVALUE_FREE(fvalue);
|
||||
} else {
|
||||
value_str = NULL;
|
||||
stripped_value_str = NULL;
|
||||
|
|
Loading…
Reference in New Issue