diff options
author | Guy Harris <guy@alum.mit.edu> | 2019-04-07 17:22:23 -0700 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2019-04-08 00:55:52 +0000 |
commit | 9f575c8dc9a04c1eb4634cf525815ff226a5e1bf (patch) | |
tree | 77b7b6739df4ec1a8c43256e04b0cf29aab44391 /ui/proto_hier_stats.c | |
parent | ae3e6712f3e3c7148f5a9d60b703b25ce11e2f37 (diff) | |
download | wireshark-9f575c8dc9a04c1eb4634cf525815ff226a5e1bf.tar.gz wireshark-9f575c8dc9a04c1eb4634cf525815ff226a5e1bf.tar.bz2 wireshark-9f575c8dc9a04c1eb4634cf525815ff226a5e1bf.zip |
Use a common wtap_rec and Buffer for all packets.
That way we don't do initialization, possible expansion of the buffer
from its initial size, and cleanup for every packet.
Change-Id: If967bd8f0cc65631b8b128b2c048d32ba54c8033
Reviewed-on: https://code.wireshark.org/review/32774
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/proto_hier_stats.c')
-rw-r--r-- | ui/proto_hier_stats.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/ui/proto_hier_stats.c b/ui/proto_hier_stats.c index d216f0101b..ec17d79fe5 100644 --- a/ui/proto_hier_stats.c +++ b/ui/proto_hier_stats.c @@ -27,7 +27,7 @@ static int pc_proto_id = -1; -static GNode* + static GNode* find_stat_node(GNode *parent_stat_node, header_field_info *needle_hfinfo) { GNode *needle_stat_node, *up_parent_stat_node; @@ -147,26 +147,22 @@ process_tree(proto_tree *protocol_tree, ph_stats_t* ps) } static gboolean -process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats_t* ps) +process_record(capture_file *cf, frame_data *frame, column_info *cinfo, + wtap_rec *rec, Buffer *buf, ph_stats_t* ps) { epan_dissect_t edt; - wtap_rec rec; - Buffer buf; double cur_time; - wtap_rec_init(&rec); - /* Load the record from the capture file */ - ws_buffer_init(&buf, 1514); - if (!cf_read_record_r(cf, frame, &rec, &buf)) + if (!cf_read_record_r(cf, frame, rec, buf)) return FALSE; /* failure */ /* Dissect the record tree not visible */ epan_dissect_init(&edt, cf->epan, TRUE, FALSE); /* Don't fake protocols. We need them for the protocol hierarchy */ epan_dissect_fake_protocols(&edt, FALSE); - epan_dissect_run(&edt, cf->cd_t, &rec, - frame_tvbuff_new_buffer(&cf->provider, frame, &buf), + epan_dissect_run(&edt, cf->cd_t, rec, + frame_tvbuff_new_buffer(&cf->provider, frame, buf), frame, cinfo); /* Get stats from this protocol tree */ @@ -183,8 +179,6 @@ process_record(capture_file *cf, frame_data *frame, column_info *cinfo, ph_stats /* Free our memory. */ epan_dissect_cleanup(&edt); - wtap_rec_cleanup(&rec); - ws_buffer_free(&buf); return TRUE; /* success */ } @@ -199,6 +193,8 @@ ph_stats_new(capture_file *cf) progdlg_t *progbar = NULL; gboolean stop_flag; int count; + wtap_rec rec; + Buffer buf; float progbar_val; GTimeVal start_time; gchar status_str[100]; @@ -233,6 +229,9 @@ ph_stats_new(capture_file *cf) tot_packets = 0; tot_bytes = 0; + wtap_rec_init(&rec); + ws_buffer_init(&buf, 1514); + for (framenum = 1; framenum <= cf->count; framenum++) { frame = frame_data_sequence_find(cf->provider.frames, framenum); @@ -293,7 +292,7 @@ ph_stats_new(capture_file *cf) } /* we don't care about colinfo */ - if (!process_record(cf, frame, NULL, ps)) { + if (!process_record(cf, frame, NULL, &rec, &buf, ps)) { /* * Give up, and set "stop_flag" so we * just abort rather than popping up @@ -310,6 +309,9 @@ ph_stats_new(capture_file *cf) count++; } + wtap_rec_cleanup(&rec); + ws_buffer_free(&buf); + /* We're done calculating the statistics; destroy the progress bar if it was created. */ if (progbar != NULL) |