Skip to content

Commit

Permalink
Replace hfinfo pointer to same_name_prev, with same_name_prev_id.
Browse files Browse the repository at this point in the history
svn path=/trunk/; revision=51175
  • Loading branch information
jwzawadzki committed Aug 6, 2013
1 parent 72ea2f9 commit 9cfac12
Show file tree
Hide file tree
Showing 16 changed files with 44 additions and 36 deletions.
2 changes: 1 addition & 1 deletion asn1/ldap/packet-ldap-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,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);
Expand Down
8 changes: 4 additions & 4 deletions epan/dfilter/gencode.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions epan/dfilter/semcheck.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-http.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-imf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-ldap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-tpncp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-xml.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
28 changes: 18 additions & 10 deletions epan/proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
5 changes: 2 additions & 3 deletions epan/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -373,17 +373,16 @@ 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 */
};

/**
* HFILL initializes all the "set by proto routines" fields in a
* _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 {
Expand Down
3 changes: 2 additions & 1 deletion epan/wslua/wslua_field.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 */
Expand Down
2 changes: 1 addition & 1 deletion epan/wspython/wspy_proto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion plugins/mate/mate_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extern gboolean add_hfid(header_field_info* hfi, gchar* how, GHashTable* where)

while(hfi) {
first_hfi = hfi;
hfi = hfi->same_name_prev;
hfi = (hfi->same_name_prev_id != -1) ? proto_registrar_get_nth(hfi->same_name_prev_id) : NULL;
}

hfi = first_hfi;
Expand Down
2 changes: 1 addition & 1 deletion ui/gtk/filter_autocomplete.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ build_autocompletion_list(GtkWidget *filter_te, GtkWidget *treeview, GtkWidget *
hfinfo != NULL;
hfinfo = proto_get_next_protocol_field(&cookie2))
{
if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */
continue;

if(!g_ascii_strncasecmp(protocol_name, hfinfo->abbrev, protocol_name_len)) {
Expand Down
8 changes: 4 additions & 4 deletions ui/gtk/proto_hier_tree_model.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ proto_hier_tree_iter_nth_child(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkT
/* get n-th field of protocol */
hfinfo = proto_get_first_protocol_field(proto_id, &cookie);
while (hfinfo) {
if (hfinfo->same_name_prev == NULL) {
if (hfinfo->same_name_prev_id == -1) {
if (!n)
break;
n--;
Expand Down Expand Up @@ -244,7 +244,7 @@ proto_hier_tree_iter_next(GtkTreeModel *tree_model, GtkTreeIter *iter)
hfinfo = proto_get_next_protocol_field(&cookie2);
/* get next field */
while (hfinfo) {
if (hfinfo->same_name_prev == NULL)
if (hfinfo->same_name_prev_id == -1)
break;
hfinfo = proto_get_next_protocol_field(&cookie2);
}
Expand Down Expand Up @@ -292,7 +292,7 @@ proto_hier_tree_iter_n_children(GtkTreeModel *tree_model, GtkTreeIter *iter)

/* count not-duplicated fields */
for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo; hfinfo = proto_get_next_protocol_field(&cookie)) {
if (hfinfo->same_name_prev)
if (hfinfo->same_name_prev_id != -1)
continue;
count++;
}
Expand Down Expand Up @@ -353,7 +353,7 @@ proto_hier_tree_get_path(GtkTreeModel *tree_model, GtkTreeIter *iter)

pos = 0;
for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo && hfinfo != iter->user_data3; hfinfo = proto_get_next_protocol_field(&cookie)) {
if (hfinfo->same_name_prev)
if (hfinfo->same_name_prev_id != -1)
continue;
pos++;
}
Expand Down
6 changes: 3 additions & 3 deletions ui/gtk/supported_protos_dlg.c
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ static void set_supported_text(GtkWidget *w, supported_type_t type)
for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
hfinfo = proto_get_next_protocol_field(&cookie2)) {

if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */
continue;

if ((len = (int) strlen(hfinfo->abbrev)) > maxlen)
Expand Down Expand Up @@ -287,7 +287,7 @@ static void set_supported_text(GtkWidget *w, supported_type_t type)
for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
hfinfo = proto_get_next_protocol_field(&cookie2)) {

if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */
continue;
count++;
}
Expand All @@ -300,7 +300,7 @@ static void set_supported_text(GtkWidget *w, supported_type_t type)
for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL;
hfinfo = proto_get_next_protocol_field(&cookie2)) {

if (hfinfo->same_name_prev != NULL) /* ignore duplicate names */
if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */
continue;

type_name = ftype_pretty_name(hfinfo->type);
Expand Down

0 comments on commit 9cfac12

Please sign in to comment.