aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorJakub Zawadzki <darkjames-ws@darkjames.pl>2013-08-06 20:53:47 +0000
committerJakub Zawadzki <darkjames-ws@darkjames.pl>2013-08-06 20:53:47 +0000
commit9cfac1227d8fd1f6de1d9e47489ea49616a2bee2 (patch)
treef48731d0b0c293e6af6f3476eae8fef06908059f /epan
parent72ea2f9c9c63c7e5c6270383888ad32683d96edf (diff)
Replace hfinfo pointer to same_name_prev, with same_name_prev_id.
svn path=/trunk/; revision=51175
Diffstat (limited to 'epan')
-rw-r--r--epan/dfilter/gencode.c8
-rw-r--r--epan/dfilter/semcheck.c4
-rw-r--r--epan/dissectors/packet-http.c2
-rw-r--r--epan/dissectors/packet-imf.c2
-rw-r--r--epan/dissectors/packet-ldap.c2
-rw-r--r--epan/dissectors/packet-tpncp.c2
-rw-r--r--epan/dissectors/packet-xml.c2
-rw-r--r--epan/proto.c28
-rw-r--r--epan/proto.h5
-rw-r--r--epan/wslua/wslua_field.c3
-rw-r--r--epan/wspython/wspy_proto.c2
11 files changed, 34 insertions, 26 deletions
diff --git a/epan/dfilter/gencode.c b/epan/dfilter/gencode.c
index 8571d47a2b..f977c77ede 100644
--- a/epan/dfilter/gencode.c
+++ b/epan/dfilter/gencode.c
@@ -63,8 +63,8 @@ dfw_append_read_tree(dfwork_t *dfw, header_field_info *hfinfo)
gboolean added_new_hfinfo = FALSE;
/* Rewind to find the first field of this name. */
- while (hfinfo->same_name_prev) {
- hfinfo = hfinfo->same_name_prev;
+ while (hfinfo->same_name_prev_id != -1) {
+ hfinfo = proto_registrar_get_nth(hfinfo->same_name_prev_id);
}
/* Keep track of which registers
@@ -341,8 +341,8 @@ gen_test(dfwork_t *dfw, stnode_t *st_node)
hfinfo = (header_field_info*)stnode_data(st_arg1);
/* Rewind to find the first field of this name. */
- while (hfinfo->same_name_prev) {
- hfinfo = hfinfo->same_name_prev;
+ while (hfinfo->same_name_prev_id != -1) {
+ hfinfo = proto_registrar_get_nth(hfinfo->same_name_prev_id);
}
val1->value.hfinfo = hfinfo;
insn = dfvm_insn_new(CHECK_EXISTS);
diff --git a/epan/dfilter/semcheck.c b/epan/dfilter/semcheck.c
index ea5cb99e17..47dd748da3 100644
--- a/epan/dfilter/semcheck.c
+++ b/epan/dfilter/semcheck.c
@@ -618,8 +618,8 @@ check_relation_LHS_FIELD(const char *relation_string, FtypeCanFunc can_func,
}
if (!fvalue) {
/* Try another field with the same name */
- if (hfinfo1->same_name_prev) {
- hfinfo1 = hfinfo1->same_name_prev;
+ if (hfinfo1->same_name_prev_id != -1) {
+ hfinfo1 = proto_registrar_get_nth(hfinfo1->same_name_prev_id);
ftype1 = hfinfo1->type;
} else {
break;
diff --git a/epan/dissectors/packet-http.c b/epan/dissectors/packet-http.c
index 17a4e3367f..b8fe8bf82f 100644
--- a/epan/dissectors/packet-http.c
+++ b/epan/dissectors/packet-http.c
@@ -2290,7 +2290,7 @@ header_fields_initialize_cb(void)
hf[i].hfinfo.display = BASE_NONE;
hf[i].hfinfo.strings = NULL;
hf[i].hfinfo.blurb = g_strdup(header_fields[i].header_desc);
- hf[i].hfinfo.same_name_prev = NULL;
+ hf[i].hfinfo.same_name_prev_id = -1;
hf[i].hfinfo.same_name_next = NULL;
g_hash_table_insert(header_fields_hash, header_name, hf_id);
diff --git a/epan/dissectors/packet-imf.c b/epan/dissectors/packet-imf.c
index 7056031b3c..2e26c3b6b8 100644
--- a/epan/dissectors/packet-imf.c
+++ b/epan/dissectors/packet-imf.c
@@ -895,7 +895,7 @@ header_fields_initialize_cb (void)
hf[i].hfinfo.display = BASE_NONE;
hf[i].hfinfo.strings = NULL;
hf[i].hfinfo.blurb = g_strdup (header_fields[i].description);
- hf[i].hfinfo.same_name_prev = NULL;
+ hf[i].hfinfo.same_name_prev_id = -1;
hf[i].hfinfo.same_name_next = NULL;
imffield = (struct imf_field *)g_malloc (sizeof (struct imf_field));
diff --git a/epan/dissectors/packet-ldap.c b/epan/dissectors/packet-ldap.c
index a1b0dd6a12..1d9194e763 100644
--- a/epan/dissectors/packet-ldap.c
+++ b/epan/dissectors/packet-ldap.c
@@ -734,7 +734,7 @@ attribute_types_initialize_cb(void)
hf[i].hfinfo.display = BASE_NONE;
hf[i].hfinfo.strings = NULL;
hf[i].hfinfo.blurb = g_strdup(attribute_types[i].attribute_desc);
- hf[i].hfinfo.same_name_prev = NULL;
+ hf[i].hfinfo.same_name_prev_id = -1;
hf[i].hfinfo.same_name_next = NULL;
g_hash_table_insert(attribute_types_hash, attribute_type, hf_id);
diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c
index e1ed09d0be..9248cf285e 100644
--- a/epan/dissectors/packet-tpncp.c
+++ b/epan/dissectors/packet-tpncp.c
@@ -584,7 +584,7 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info,
hf_entr.hfinfo.parent = 0;
hf_entr.hfinfo.ref_type = HF_REF_TYPE_NONE;
hf_entr.hfinfo.same_name_next = NULL;
- hf_entr.hfinfo.same_name_prev = NULL;
+ hf_entr.hfinfo.same_name_prev_id = -1;
if (!was_registered) {
/* Register non-standard data should be done only once. */
diff --git a/epan/dissectors/packet-xml.c b/epan/dissectors/packet-xml.c
index 9569167b38..52617a6269 100644
--- a/epan/dissectors/packet-xml.c
+++ b/epan/dissectors/packet-xml.c
@@ -817,7 +817,7 @@ static void add_xml_field(wmem_array_t *hfs, int *p_id, const gchar *name, const
hfri.hfinfo.parent = 0;
hfri.hfinfo.ref_type = HF_REF_TYPE_NONE;
hfri.hfinfo.same_name_next = NULL;
- hfri.hfinfo.same_name_prev = NULL;
+ hfri.hfinfo.same_name_prev_id = -1;
wmem_array_append_one(hfs, hfri);
}
diff --git a/epan/proto.c b/epan/proto.c
index 03ee55fab6..08ae656dcd 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -3610,6 +3610,14 @@ protoo_strlcpy(gchar *dest, const gchar *src, gsize dest_size)
return (int) res;
}
+static header_field_info *
+hfinfo_same_name_get_prev(const header_field_info *hfinfo)
+{
+ if (hfinfo->same_name_prev_id == -1)
+ return NULL;
+ return proto_registrar_get_nth(hfinfo->same_name_prev_id);
+}
+
/* -------------------------- */
const gchar *
proto_custom_set(proto_tree* tree, const int field_id, gint occurrence,
@@ -3644,8 +3652,8 @@ proto_custom_set(proto_tree* tree, const int field_id, gint occurrence,
if (occurrence < 0) {
/* Search other direction */
- while (hfinfo->same_name_prev) {
- hfinfo = hfinfo->same_name_prev;
+ while (hfinfo->same_name_prev_id != -1) {
+ hfinfo = proto_registrar_get_nth(hfinfo->same_name_prev_id);
}
}
@@ -3656,7 +3664,7 @@ proto_custom_set(proto_tree* tree, const int field_id, gint occurrence,
if (occurrence < 0) {
hfinfo = hfinfo->same_name_next;
} else {
- hfinfo = hfinfo->same_name_prev;
+ hfinfo = hfinfo_same_name_get_prev(hfinfo);
}
continue;
}
@@ -3666,7 +3674,7 @@ proto_custom_set(proto_tree* tree, const int field_id, gint occurrence,
if (occurrence < 0) {
hfinfo = hfinfo->same_name_next;
} else {
- hfinfo = hfinfo->same_name_prev;
+ hfinfo = hfinfo_same_name_get_prev(hfinfo);
}
prev_len += len;
continue;
@@ -3917,7 +3925,7 @@ proto_custom_set(proto_tree* tree, const int field_id, gint occurrence,
if (occurrence == 0) {
/* Fetch next hfinfo with same name (abbrev) */
- hfinfo = hfinfo->same_name_prev;
+ hfinfo = hfinfo_same_name_get_prev(hfinfo);
} else {
hfinfo = NULL;
}
@@ -4959,7 +4967,7 @@ proto_register_field_init(header_field_info *hfinfo, const int parent)
hfinfo->parent = parent;
hfinfo->same_name_next = NULL;
- hfinfo->same_name_prev = NULL;
+ hfinfo->same_name_prev_id = -1;
/* if we always add and never delete, then id == len - 1 is correct */
if (gpa_hfinfo.len >= gpa_hfinfo.allocated_len) {
@@ -5018,10 +5026,10 @@ proto_register_field_init(header_field_info *hfinfo, const int parent)
hfinfo->same_name_next = same_name_next_hfinfo;
if (same_name_next_hfinfo)
- same_name_next_hfinfo->same_name_prev = hfinfo;
+ same_name_next_hfinfo->same_name_prev_id = hfinfo->id;
same_name_hfinfo->same_name_next = hfinfo;
- hfinfo->same_name_prev = same_name_hfinfo;
+ hfinfo->same_name_prev_id = same_name_hfinfo->id;
}
}
@@ -6111,7 +6119,7 @@ proto_registrar_dump_values(void)
* *maximum* length is 2 bytes, and be used
* for all lengths.)
*/
- if (hfinfo->same_name_prev != NULL)
+ if (hfinfo->same_name_prev_id != -1)
continue;
vals = NULL;
@@ -6286,7 +6294,7 @@ proto_registrar_dump_fields(void)
* *maximum* length is 2 bytes, and be used
* for all lengths.)
*/
- if (hfinfo->same_name_prev != NULL)
+ if (hfinfo->same_name_prev_id != -1)
continue;
PROTO_REGISTRAR_GET_NTH(hfinfo->parent, parent_hfinfo);
diff --git a/epan/proto.h b/epan/proto.h
index 8dfd85a05b..ee821185b1 100644
--- a/epan/proto.h
+++ b/epan/proto.h
@@ -373,9 +373,8 @@ struct _header_field_info {
int id; /**< Field ID */
int parent; /**< parent protocol tree */
hf_ref_type ref_type; /**< is this field referenced by a filter */
- /* 4B padding */
+ int same_name_prev_id; /**< ID of previous hfinfo with same abbrev */
header_field_info *same_name_next; /**< Link to next hfinfo with same abbrev */
- header_field_info *same_name_prev; /**< Link to previous hfinfo with same abbrev */
};
/**
@@ -383,7 +382,7 @@ struct _header_field_info {
* _header_field_info. If new fields are added or removed, it should
* be changed as necessary.
*/
-#define HFILL 0, 0, HF_REF_TYPE_NONE, NULL, NULL
+#define HFILL 0, 0, HF_REF_TYPE_NONE, -1, NULL
/** Used when registering many fields at once, using proto_register_field_array() */
typedef struct hf_register_info {
diff --git a/epan/wslua/wslua_field.c b/epan/wslua/wslua_field.c
index 242e32c202..f5fd6e9675 100644
--- a/epan/wslua/wslua_field.c
+++ b/epan/wslua/wslua_field.c
@@ -502,7 +502,7 @@ WSLUA_METAMETHOD Field__call (lua_State* L) {
WSLUA_ERROR(Field__call,"Fields cannot be used outside dissectors or taps");
}
- for (;in;in = in->same_name_prev) {
+ while (in) {
GPtrArray* found = proto_get_finfo_ptr_array(lua_tree->tree, in->id);
guint i;
if (found) {
@@ -511,6 +511,7 @@ WSLUA_METAMETHOD Field__call (lua_State* L) {
items_found++;
}
}
+ in = (in->same_name_prev_id != -1) ? proto_registrar_get_nth(in->same_name_prev_id) : NULL;
}
WSLUA_RETURN(items_found); /* All the values of this field */
diff --git a/epan/wspython/wspy_proto.c b/epan/wspython/wspy_proto.c
index e315a73e2a..d28b9526eb 100644
--- a/epan/wspython/wspy_proto.c
+++ b/epan/wspython/wspy_proto.c
@@ -70,7 +70,7 @@ void hf_register_info_add(hf_register_info *hf, guint8 index,
hf[index].hfinfo.parent = 0;
hf[index].hfinfo.ref_type = HF_REF_TYPE_NONE;
hf[index].hfinfo.same_name_next = NULL;
- hf[index].hfinfo.same_name_prev = NULL;
+ hf[index].hfinfo.same_name_prev_id = -1;
}
void hf_register_info_print(hf_register_info *hf, guint8 size)