aboutsummaryrefslogtreecommitdiffstats
path: root/ui/gtk/proto_hier_tree_model.c
diff options
context:
space:
mode:
authorEvan Huus <eapache@gmail.com>2014-04-20 17:27:18 -0400
committerEvan Huus <eapache@gmail.com>2014-04-21 15:37:06 +0000
commitd47ae54806201a868b7e012e52d1bab19b78ae06 (patch)
treea5f6bd1a761ee2c1545eeae3fa8f0e934315caec /ui/gtk/proto_hier_tree_model.c
parent5983cda769fa6615dda5fc7b8f87819d40f0a8d5 (diff)
Replace linked list of proto fields with array
This is substantially more memory-efficient, shaving another ~1.5MB off our base usage. It also lets us remove the annoying extra "last_field" pointer and simplify proto_register_field_common(). It also accidentally fixed what may have been a memory leak in proto_unregister_field(). It unfortunately complicates proto_get_next_protocol_field() to require refetching the protocol each time, but that is itself just an array-lookup under the covers (and isn't much used), so I don't expect the performance hit to be noticable. Change-Id: I8e1006b2326d6563fc3b710b827cc99b54440df1 Reviewed-on: https://code.wireshark.org/review/1225 Reviewed-by: Michael Mann <mmann78@netscape.net> Reviewed-by: Evan Huus <eapache@gmail.com>
Diffstat (limited to 'ui/gtk/proto_hier_tree_model.c')
-rw-r--r--ui/gtk/proto_hier_tree_model.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/ui/gtk/proto_hier_tree_model.c b/ui/gtk/proto_hier_tree_model.c
index 6ae13f610d..5ba701f82f 100644
--- a/ui/gtk/proto_hier_tree_model.c
+++ b/ui/gtk/proto_hier_tree_model.c
@@ -98,7 +98,7 @@ proto_hier_tree_iter_nth_child(GtkTreeModel *tree_model, GtkTreeIter *iter, GtkT
break;
n--;
}
- hfinfo = proto_get_next_protocol_field(&cookie);
+ hfinfo = proto_get_next_protocol_field(proto_id, &cookie);
}
/* not found? */
@@ -238,13 +238,14 @@ proto_hier_tree_iter_next(GtkTreeModel *tree_model, GtkTreeIter *iter)
{
void *cookie2 = iter->user_data2;
header_field_info *hfinfo;
+ int proto_id = proto_get_data_protocol(iter->user_data);
- hfinfo = proto_get_next_protocol_field(&cookie2);
+ hfinfo = proto_get_next_protocol_field(proto_id, &cookie2);
/* get next field */
while (hfinfo) {
if (hfinfo->same_name_prev_id == -1)
break;
- hfinfo = proto_get_next_protocol_field(&cookie2);
+ hfinfo = proto_get_next_protocol_field(proto_id, &cookie2);
}
/* not found? */
@@ -289,7 +290,7 @@ proto_hier_tree_iter_n_children(GtkTreeModel *tree_model, GtkTreeIter *iter)
p_id = proto_get_data_protocol(iter->user_data);
/* count not-duplicated fields */
- for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo; hfinfo = proto_get_next_protocol_field(&cookie)) {
+ for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo; hfinfo = proto_get_next_protocol_field(p_id, &cookie)) {
if (hfinfo->same_name_prev_id != -1)
continue;
count++;
@@ -350,7 +351,7 @@ proto_hier_tree_get_path(GtkTreeModel *tree_model, GtkTreeIter *iter)
header_field_info *hfinfo;
pos = 0;
- for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo && hfinfo != iter->user_data3; hfinfo = proto_get_next_protocol_field(&cookie)) {
+ for (hfinfo = proto_get_first_protocol_field(p_id, &cookie); hfinfo && hfinfo != iter->user_data3; hfinfo = proto_get_next_protocol_field(p_id, &cookie)) {
if (hfinfo->same_name_prev_id != -1)
continue;
pos++;