aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-12-03 09:28:26 +0000
committerGuy Harris <guy@alum.mit.edu>2003-12-03 09:28:26 +0000
commitdcd98ae8d334081d0b4e0f4c6902ac128dfeb000 (patch)
tree1d14652d65d1690cfc1980777b9bc90aac75b4c2 /epan
parented2ae2d8d3eb9bdf13562825d28a7a60869b5c56 (diff)
The "ptr_u" unions no longer have a "next" pointer - they now just have
one member - or have one that's not used, so get rid of those unions. svn path=/trunk/; revision=9151
Diffstat (limited to 'epan')
-rw-r--r--epan/ftypes/ftypes.c84
-rw-r--r--epan/ftypes/ftypes.h8
-rw-r--r--epan/proto.c49
-rw-r--r--epan/proto.h11
4 files changed, 71 insertions, 81 deletions
diff --git a/epan/ftypes/ftypes.c b/epan/ftypes/ftypes.c
index 6567a34807..43b437a49d 100644
--- a/epan/ftypes/ftypes.c
+++ b/epan/ftypes/ftypes.c
@@ -1,5 +1,5 @@
/*
- * $Id: ftypes.c,v 1.17 2003/12/03 08:53:37 guy Exp $
+ * $Id: ftypes.c,v 1.18 2003/12/03 09:28:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -196,7 +196,7 @@ fvalue_new(ftenum_t ftype)
SLAB_ALLOC(fv, fvalue_free_list);
FTYPE_LOOKUP(ftype, ft);
- fv->ptr_u.ftype = ft;
+ fv->ftype = ft;
new_value = ft->new_value;
if (new_value) {
@@ -213,7 +213,7 @@ fvalue_init(fvalue_t *fv, ftenum_t ftype)
FvalueNewFunc new_value;
FTYPE_LOOKUP(ftype, ft);
- fv->ptr_u.ftype = ft;
+ fv->ftype = ft;
new_value = ft->new_value;
if (new_value) {
@@ -227,8 +227,8 @@ fvalue_from_unparsed(ftenum_t ftype, char *s, gboolean allow_partial_value, LogF
fvalue_t *fv;
fv = fvalue_new(ftype);
- if (fv->ptr_u.ftype->val_from_unparsed) {
- if (fv->ptr_u.ftype->val_from_unparsed(fv, s, allow_partial_value, logfunc)) {
+ if (fv->ftype->val_from_unparsed) {
+ if (fv->ftype->val_from_unparsed(fv, s, allow_partial_value, logfunc)) {
return fv;
}
}
@@ -246,8 +246,8 @@ fvalue_from_string(ftenum_t ftype, char *s, LogFunc logfunc)
fvalue_t *fv;
fv = fvalue_new(ftype);
- if (fv->ptr_u.ftype->val_from_string) {
- if (fv->ptr_u.ftype->val_from_string(fv, s, logfunc)) {
+ if (fv->ftype->val_from_string) {
+ if (fv->ftype->val_from_string(fv, s, logfunc)) {
return fv;
}
}
@@ -262,34 +262,34 @@ fvalue_from_string(ftenum_t ftype, char *s, LogFunc logfunc)
const char*
fvalue_type_name(fvalue_t *fv)
{
- return fv->ptr_u.ftype->name;
+ return fv->ftype->name;
}
guint
fvalue_length(fvalue_t *fv)
{
- if (fv->ptr_u.ftype->len)
- return fv->ptr_u.ftype->len(fv);
+ if (fv->ftype->len)
+ return fv->ftype->len(fv);
else
- return fv->ptr_u.ftype->wire_size;
+ return fv->ftype->wire_size;
}
int
fvalue_string_repr_len(fvalue_t *fv, ftrepr_t rtype)
{
- g_assert(fv->ptr_u.ftype->len_string_repr);
- return fv->ptr_u.ftype->len_string_repr(fv, rtype);
+ g_assert(fv->ftype->len_string_repr);
+ return fv->ftype->len_string_repr(fv, rtype);
}
char *
fvalue_to_string_repr(fvalue_t *fv, ftrepr_t rtype, char *buf)
{
- g_assert(fv->ptr_u.ftype->val_to_string_repr);
+ g_assert(fv->ftype->val_to_string_repr);
if (!buf) {
buf = g_malloc0(fvalue_string_repr_len(fv, rtype) + 1);
}
- fv->ptr_u.ftype->val_to_string_repr(fv, rtype, buf);
+ fv->ftype->val_to_string_repr(fv, rtype, buf);
return buf;
}
@@ -375,7 +375,7 @@ slice_func(gpointer data, gpointer user_data)
return;
}
- fv->ptr_u.ftype->slice(fv, slice_data->bytes, start_offset, length);
+ fv->ftype->slice(fv, slice_data->bytes, start_offset, length);
}
@@ -406,98 +406,98 @@ fvalue_slice(fvalue_t *fv, drange *drange)
void
fvalue_set(fvalue_t *fv, gpointer value, gboolean already_copied)
{
- g_assert(fv->ptr_u.ftype->set_value);
- fv->ptr_u.ftype->set_value(fv, value, already_copied);
+ g_assert(fv->ftype->set_value);
+ fv->ftype->set_value(fv, value, already_copied);
}
void
fvalue_set_integer(fvalue_t *fv, guint32 value)
{
- g_assert(fv->ptr_u.ftype->set_value_integer);
- fv->ptr_u.ftype->set_value_integer(fv, value);
+ g_assert(fv->ftype->set_value_integer);
+ fv->ftype->set_value_integer(fv, value);
}
void
fvalue_set_floating(fvalue_t *fv, gdouble value)
{
- g_assert(fv->ptr_u.ftype->set_value_floating);
- fv->ptr_u.ftype->set_value_floating(fv, value);
+ g_assert(fv->ftype->set_value_floating);
+ fv->ftype->set_value_floating(fv, value);
}
gpointer
fvalue_get(fvalue_t *fv)
{
- g_assert(fv->ptr_u.ftype->get_value);
- return fv->ptr_u.ftype->get_value(fv);
+ g_assert(fv->ftype->get_value);
+ return fv->ftype->get_value(fv);
}
guint32
fvalue_get_integer(fvalue_t *fv)
{
- g_assert(fv->ptr_u.ftype->get_value_integer);
- return fv->ptr_u.ftype->get_value_integer(fv);
+ g_assert(fv->ftype->get_value_integer);
+ return fv->ftype->get_value_integer(fv);
}
double
fvalue_get_floating(fvalue_t *fv)
{
- g_assert(fv->ptr_u.ftype->get_value_floating);
- return fv->ptr_u.ftype->get_value_floating(fv);
+ g_assert(fv->ftype->get_value_floating);
+ return fv->ftype->get_value_floating(fv);
}
gboolean
fvalue_eq(fvalue_t *a, fvalue_t *b)
{
/* XXX - check compatibility of a and b */
- g_assert(a->ptr_u.ftype->cmp_eq);
- return a->ptr_u.ftype->cmp_eq(a, b);
+ g_assert(a->ftype->cmp_eq);
+ return a->ftype->cmp_eq(a, b);
}
gboolean
fvalue_ne(fvalue_t *a, fvalue_t *b)
{
/* XXX - check compatibility of a and b */
- g_assert(a->ptr_u.ftype->cmp_ne);
- return a->ptr_u.ftype->cmp_ne(a, b);
+ g_assert(a->ftype->cmp_ne);
+ return a->ftype->cmp_ne(a, b);
}
gboolean
fvalue_gt(fvalue_t *a, fvalue_t *b)
{
/* XXX - check compatibility of a and b */
- g_assert(a->ptr_u.ftype->cmp_gt);
- return a->ptr_u.ftype->cmp_gt(a, b);
+ g_assert(a->ftype->cmp_gt);
+ return a->ftype->cmp_gt(a, b);
}
gboolean
fvalue_ge(fvalue_t *a, fvalue_t *b)
{
/* XXX - check compatibility of a and b */
- g_assert(a->ptr_u.ftype->cmp_ge);
- return a->ptr_u.ftype->cmp_ge(a, b);
+ g_assert(a->ftype->cmp_ge);
+ return a->ftype->cmp_ge(a, b);
}
gboolean
fvalue_lt(fvalue_t *a, fvalue_t *b)
{
/* XXX - check compatibility of a and b */
- g_assert(a->ptr_u.ftype->cmp_lt);
- return a->ptr_u.ftype->cmp_lt(a, b);
+ g_assert(a->ftype->cmp_lt);
+ return a->ftype->cmp_lt(a, b);
}
gboolean
fvalue_le(fvalue_t *a, fvalue_t *b)
{
/* XXX - check compatibility of a and b */
- g_assert(a->ptr_u.ftype->cmp_le);
- return a->ptr_u.ftype->cmp_le(a, b);
+ g_assert(a->ftype->cmp_le);
+ return a->ftype->cmp_le(a, b);
}
gboolean
fvalue_contains(fvalue_t *a, fvalue_t *b)
{
/* XXX - check compatibility of a and b */
- g_assert(a->ptr_u.ftype->cmp_contains);
- return a->ptr_u.ftype->cmp_contains(a, b);
+ g_assert(a->ftype->cmp_contains);
+ return a->ftype->cmp_contains(a, b);
}
diff --git a/epan/ftypes/ftypes.h b/epan/ftypes/ftypes.h
index b9e1067a08..00b10c8c04 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.24 2003/12/03 08:53:37 guy Exp $
+ * $Id: ftypes.h,v 1.25 2003/12/03 09:28:23 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -127,9 +127,7 @@ ftype_can_contains(enum ftenum ftype);
#include <epan/dfilter/drange.h>
typedef struct _fvalue_t {
- union {
- ftype_t *ftype;
- } ptr_u;
+ ftype_t *ftype;
union {
/* Put a few basic types in here */
gpointer pointer;
@@ -216,7 +214,7 @@ extern fvalue_t *fvalue_free_list;
#define FVALUE_CLEANUP(fv) \
{ \
register FvalueFreeFunc free_value; \
- free_value = (fv)->ptr_u.ftype->free_value; \
+ free_value = (fv)->ftype->free_value; \
if (free_value) { \
free_value((fv)); \
} \
diff --git a/epan/proto.c b/epan/proto.c
index 937c5efb5a..9d215e8ccf 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -1,7 +1,7 @@
/* proto.c
* Routines for protocol tree
*
- * $Id: proto.c,v 1.121 2003/12/03 08:53:36 guy Exp $
+ * $Id: proto.c,v 1.122 2003/12/03 09:28:22 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -569,15 +569,14 @@ proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
* good thing we saved it, now we can reverse the
* memory leak and reclaim it.
*/
- field_info_tmp->ptr_u.next=field_info_free_list;
- field_info_free_list=field_info_tmp;
+ SLAB_FREE(field_info_tmp, field_info_free_list);
}
/* we might throw an exception, keep track of this one
* across the "dangerous" section below.
*/
field_info_tmp=new_fi;
- switch(new_fi->ptr_u.hfinfo->type) {
+ switch(new_fi->hfinfo->type) {
case FT_NONE:
/* no value to set for FT_NONE */
break;
@@ -738,9 +737,9 @@ proto_tree_add_item(proto_tree *tree, int hfindex, tvbuff_t *tvb,
break;
default:
- g_error("new_fi->ptr_u.hfinfo->type %d (%s) not handled\n",
- new_fi->ptr_u.hfinfo->type,
- ftype_name(new_fi->ptr_u.hfinfo->type));
+ g_error("new_fi->hfinfo->type %d (%s) not handled\n",
+ new_fi->hfinfo->type,
+ ftype_name(new_fi->hfinfo->type));
g_assert_not_reached();
break;
}
@@ -1277,7 +1276,7 @@ proto_item_append_string(proto_item *pi, const char *str)
return;
fi = PITEM_FINFO(pi);
- hfinfo = fi->ptr_u.hfinfo;
+ hfinfo = fi->hfinfo;
g_assert(hfinfo->type == FT_STRING || hfinfo->type == FT_STRINGZ);
old_str = fvalue_get(&fi->value);
new_str = g_malloc(strlen(old_str) + strlen(str) + 1);
@@ -1638,7 +1637,7 @@ proto_tree_set_uint(field_info *fi, guint32 value)
header_field_info *hfinfo;
guint32 integer;
- hfinfo = fi->ptr_u.hfinfo;
+ hfinfo = fi->hfinfo;
integer = value;
if (hfinfo->bitmask) {
@@ -1725,7 +1724,7 @@ proto_tree_set_int(field_info *fi, gint32 value)
header_field_info *hfinfo;
guint32 integer;
- hfinfo = fi->ptr_u.hfinfo;
+ hfinfo = fi->hfinfo;
integer = (guint32) value;
if (hfinfo->bitmask) {
@@ -1883,7 +1882,7 @@ alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
FIELD_INFO_NEW(fi);
- fi->ptr_u.hfinfo = hfinfo;
+ fi->hfinfo = hfinfo;
fi->start = start;
if (tvb) {
fi->start += tvb_raw_offset(tvb);
@@ -1891,7 +1890,7 @@ alloc_field_info(proto_tree *tree, int hfindex, tvbuff_t *tvb, gint start,
fi->length = *length;
fi->tree_type = -1;
fi->visible = PTREE_DATA(tree)->visible;
- fvalue_init(&fi->value, fi->ptr_u.hfinfo->type);
+ fvalue_init(&fi->value, fi->hfinfo->type);
fi->rep = NULL;
/* add the data source tvbuff */
@@ -2491,7 +2490,7 @@ proto_register_subtree_array(gint **indices, int num_indices)
void
proto_item_fill_label(field_info *fi, gchar *label_str)
{
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
guint8 *bytes;
guint32 integer;
@@ -2676,7 +2675,7 @@ static void
fill_label_uint64(field_info *fi, gchar *label_str)
{
unsigned char *bytes;
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
int ret; /*tmp return value */
bytes=fvalue_get(&fi->value);
@@ -2705,7 +2704,7 @@ static void
fill_label_int64(field_info *fi, gchar *label_str)
{
unsigned char *bytes;
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
int ret; /*tmp return value */
bytes=fvalue_get(&fi->value);
@@ -2739,7 +2738,7 @@ fill_label_boolean(field_info *fi, gchar *label_str)
guint32 value;
int ret; /*tmp return value */
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
static const true_false_string default_tf = { "True", "False" };
const true_false_string *tfstring = &default_tf;
@@ -2782,7 +2781,7 @@ fill_label_enumerated_bitfield(field_info *fi, gchar *label_str)
guint32 value;
int ret; /*tmp return value */
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
/* Figure out the bit width */
bitwidth = hfinfo_bitwidth(hfinfo);
@@ -2818,7 +2817,7 @@ fill_label_numeric_bitfield(field_info *fi, gchar *label_str)
guint32 value;
int ret; /*tmp return value */
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
/* Figure out the bit width */
bitwidth = hfinfo_bitwidth(hfinfo);
@@ -2849,7 +2848,7 @@ static void
fill_label_enumerated_uint(field_info *fi, gchar *label_str)
{
char *format = NULL;
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
guint32 value;
int ret; /*tmp return value */
@@ -2870,7 +2869,7 @@ static void
fill_label_uint(field_info *fi, gchar *label_str)
{
char *format = NULL;
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
guint32 value;
int ret; /*tmp return value */
@@ -2889,7 +2888,7 @@ static void
fill_label_enumerated_int(field_info *fi, gchar *label_str)
{
char *format = NULL;
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
guint32 value;
int ret; /*tmp return value */
@@ -2909,7 +2908,7 @@ static void
fill_label_int(field_info *fi, gchar *label_str)
{
char *format = NULL;
- header_field_info *hfinfo = fi->ptr_u.hfinfo;
+ header_field_info *hfinfo = fi->hfinfo;
guint32 value;
int ret; /*tmp return value */
@@ -3445,7 +3444,7 @@ proto_can_match_selected(field_info *finfo, epan_dissect_t *edt)
header_field_info *hfinfo;
gint length;
- hfinfo = finfo->ptr_u.hfinfo;
+ hfinfo = finfo->hfinfo;
g_assert(hfinfo);
switch(hfinfo->type) {
@@ -3537,7 +3536,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt)
gint start, length;
guint8 c;
- hfinfo = finfo->ptr_u.hfinfo;
+ hfinfo = finfo->hfinfo;
g_assert(hfinfo);
abbrev_len = strlen(hfinfo->abbrev);
@@ -3678,7 +3677,7 @@ proto_construct_dfilter_string(field_info *finfo, epan_dissect_t *edt)
break;
case FT_PROTOCOL:
- buf = g_strdup(finfo->ptr_u.hfinfo->abbrev);
+ buf = g_strdup(finfo->hfinfo->abbrev);
break;
default:
diff --git a/epan/proto.h b/epan/proto.h
index cd557a5e67..9c0d3fa55e 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -1,7 +1,7 @@
/* proto.h
* Definitions for protocol display
*
- * $Id: proto.h,v 1.50 2003/12/03 08:53:36 guy Exp $
+ * $Id: proto.h,v 1.51 2003/12/03 09:28:22 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -109,14 +109,7 @@ typedef struct _item_label_t {
/* Contains the field information for the proto_item. */
typedef struct field_info {
- union {
- /* the next pointer is only used when keeping track of
- * free (unallocated) field_infos. Such field_info's
- * are never associated with a header_field_info.
- */
- struct field_info *next;
- header_field_info *hfinfo;
- } ptr_u;
+ header_field_info *hfinfo;
gint start;
gint length;
gint tree_type; /* ETT_* */