aboutsummaryrefslogtreecommitdiffstats
path: root/summary.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-04-25 19:01:05 +0000
committerGuy Harris <guy@alum.mit.edu>2011-04-25 19:01:05 +0000
commit71b31d92fc49ef3882fa4288ae9702cb8c848851 (patch)
treeafab88f8f3fcc36e017301acc871d2b614ff516c /summary.c
parent4e974fdc7de02deac87d8a9373198bbfa9788b00 (diff)
Store the frame_data structures in a tree, rather than a linked list.
This lets us get rid of the per-frame_data-structure prev and next pointers, saving memory (at least according to Activity Monitor's report of the virtual address space size on my Snow Leopard machine, it's a noticeable saving), and lets us look up frame_data structures by frame number in O(log2(number of frames)) time rather than O(number of frames) time. It seems to take more CPU time when reading in the file, but seems to go from "finished reading in all the packets" to "displaying the packets" faster and seems to free up the frame_data structures faster when closing the file. It *is* doing more copying, currently, as we now don't allocate the frame_data structure until after the packet has passed the read filter, so that might account for the additional CPU time. (Oh, and, for what it's worth, on an LP64 platform, a frame_data structure is exactly 128 bytes long. However, there's more stuff to remove, so the power-of-2 size is not guaranteed to remain, and it's not a power-of-2 size on an ILP32 platform.) It also means we don't need GLib 2.10 or later for the two-pass mode in TShark. It also means some code in the TCP dissector that was checking pinfo->fd->next to see if it's NULL, in order to see if this is the last packet in the file, no longer works, but that wasn't guaranteed to work anyway: we might be doing a one-pass read through the capture in TShark; we might be dissecting the frame while we're reading in the packets for the first time in Wireshark; we might be doing a live capture in Wireshark; in which case packets might be prematurely considered "the last packet". #if 0 the no-longer-working tests, pending figuring out a better way of doing it. svn path=/trunk/; revision=36849
Diffstat (limited to 'summary.c')
-rw-r--r--summary.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/summary.c b/summary.c
index cda2902..36a59e0 100644
--- a/summary.c
+++ b/summary.c
@@ -92,8 +92,7 @@ summary_fill_in(capture_file *cf, summary_tally *st)
{
frame_data *first_frame, *cur_frame;
- guint32 i;
- frame_data *cur_glist;
+ guint32 framenum;
st->start_time = 0;
st->stop_time = 0;
@@ -109,16 +108,14 @@ summary_fill_in(capture_file *cf, summary_tally *st)
st->ignored_count = 0;
/* initialize the tally */
- if (cf->plist_start != NULL) {
- first_frame = cf->plist_start;
- st->start_time = nstime_to_sec(&first_frame->abs_ts);
+ if (cf->count != 0) {
+ first_frame = cap_file_find_fdata(cf, 1);
+ st->start_time = nstime_to_sec(&first_frame->abs_ts);
st->stop_time = nstime_to_sec(&first_frame->abs_ts);
- cur_glist = cf->plist_start;
- for (i = 0; i < cf->count; i++) {
- cur_frame = cur_glist;
+ for (framenum = 1; framenum <= cf->count; framenum++) {
+ cur_frame = cap_file_find_fdata(cf, framenum);
tally_frame_data(cur_frame, st);
- cur_glist = cur_glist->next;
}
}