aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-11-25 13:20:36 +0000
committerRonnie Sahlberg <ronnie_sahlberg@ozemail.com.au>2003-11-25 13:20:36 +0000
commit4f84e65c501d246b6f73809085327dc697746238 (patch)
tree90ede99a7f1ad51c7a59e34c6ae6672bb4c33130 /epan
parent0bf28e51afb4c44fb43c29b03e7a2284629f6a6f (diff)
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
Diffstat (limited to 'epan')
-rw-r--r--epan/dfilter/dfvm.c4
-rw-r--r--epan/ftypes/ftype-ipv4.c4
-rw-r--r--epan/ftypes/ftype-string.c4
-rw-r--r--epan/ftypes/ftypes-int.h57
-rw-r--r--epan/ftypes/ftypes.c23
-rw-r--r--epan/ftypes/ftypes.h74
-rw-r--r--epan/proto.c5
7 files changed, 84 insertions, 87 deletions
diff --git a/epan/dfilter/dfvm.c b/epan/dfilter/dfvm.c
index 85753468f1..dc8910878a 100644
--- a/epan/dfilter/dfvm.c
+++ b/epan/dfilter/dfvm.c
@@ -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);
diff --git a/epan/ftypes/ftype-ipv4.c b/epan/ftypes/ftype-ipv4.c
index c5362bfbca..107b5c2525 100644
--- a/epan/ftypes/ftype-ipv4.c
+++ b/epan/ftypes/ftype-ipv4.c
@@ -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",
diff --git a/epan/ftypes/ftype-string.c b/epan/ftypes/ftype-string.c
index 8a8d3aeaa3..4abdeca986 100644
--- a/epan/ftypes/ftype-string.c
+++ b/epan/ftypes/ftype-string.c
@@ -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 {
diff --git a/epan/ftypes/ftypes-int.h b/epan/ftypes/ftypes-int.h
index 2ba2e2fde3..818785894b 100644
--- a/epan/ftypes/ftypes-int.h
+++ b/epan/ftypes/ftypes-int.h
@@ -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);
diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c
index e45d98466e..c924c44d8d 100644
--- a/epan/ftypes/ftypes.c
+++ b/epan/ftypes/ftypes.c
@@ -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;
}
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index 7c7bb7790e..fc0ec3d2b6 100644
--- a/epan/ftypes/ftypes.h
+++ b/epan/ftypes/ftypes.h
@@ -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);
diff --git a/epan/proto.c b/epan/proto.c
index 5c0eab241c..3ee0d5b93c 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -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);
}