diff options
author | Evan Huus <eapache@gmail.com> | 2014-04-20 17:27:18 -0400 |
---|---|---|
committer | Evan Huus <eapache@gmail.com> | 2014-04-21 15:37:06 +0000 |
commit | d47ae54806201a868b7e012e52d1bab19b78ae06 (patch) | |
tree | a5f6bd1a761ee2c1545eeae3fa8f0e934315caec /ui/gtk | |
parent | 5983cda769fa6615dda5fc7b8f87819d40f0a8d5 (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')
-rw-r--r-- | ui/gtk/filter_autocomplete.c | 2 | ||||
-rw-r--r-- | ui/gtk/proto_hier_tree_model.c | 11 | ||||
-rw-r--r-- | ui/gtk/supported_protos_dlg.c | 6 |
3 files changed, 10 insertions, 9 deletions
diff --git a/ui/gtk/filter_autocomplete.c b/ui/gtk/filter_autocomplete.c index 3978bc04e3..91048aa052 100644 --- a/ui/gtk/filter_autocomplete.c +++ b/ui/gtk/filter_autocomplete.c @@ -657,7 +657,7 @@ build_autocompletion_list(GtkWidget *filter_te, GtkWidget *treeview, GtkWidget * for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL; - hfinfo = proto_get_next_protocol_field(&cookie2)) + hfinfo = proto_get_next_protocol_field(i, &cookie2)) { if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */ continue; 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++; diff --git a/ui/gtk/supported_protos_dlg.c b/ui/gtk/supported_protos_dlg.c index ffb7c20d68..4609bd1e91 100644 --- a/ui/gtk/supported_protos_dlg.c +++ b/ui/gtk/supported_protos_dlg.c @@ -255,7 +255,7 @@ static void set_supported_text(GtkWidget *w, supported_type_t type) i = proto_get_next_protocol(&cookie)) { for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL; - hfinfo = proto_get_next_protocol_field(&cookie2)) { + hfinfo = proto_get_next_protocol_field(i, &cookie2)) { if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */ continue; @@ -283,7 +283,7 @@ static void set_supported_text(GtkWidget *w, supported_type_t type) count = 0; for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL; - hfinfo = proto_get_next_protocol_field(&cookie2)) { + hfinfo = proto_get_next_protocol_field(i, &cookie2)) { if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */ continue; @@ -296,7 +296,7 @@ static void set_supported_text(GtkWidget *w, supported_type_t type) insert_text(w, buffer, len); for (hfinfo = proto_get_first_protocol_field(i, &cookie2); hfinfo != NULL; - hfinfo = proto_get_next_protocol_field(&cookie2)) { + hfinfo = proto_get_next_protocol_field(i, &cookie2)) { if (hfinfo->same_name_prev_id != -1) /* ignore duplicate names */ continue; |