forked from osmocom/wireshark
Replace hfinfo pointer to same_name_prev, with same_name_prev_id.
svn path=/trunk/; revision=51175
This commit is contained in:
parent
72ea2f9c9c
commit
9cfac1227d
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
28
epan/proto.c
28
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);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -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--;
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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++;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
@ -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++;
|
||||
}
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue