diff options
author | Steven Rostedt <srostedt@redhat.com> | 2010-01-04 21:44:20 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2010-01-04 21:44:20 -0500 |
commit | 445e2e6cfde4f01fd84e5ae9cc4a590418886bb7 (patch) | |
tree | d584a6f4f6d91a65d274988a2795ad4fba3402ac | |
parent | b568a38880bb7885aab7e16ca27634a2dd6b2c9e (diff) |
trace-view: Fix trace_view_store_get_timestamp_visible_row()
The search used the size of the actual_rows array, and not the
size of what was visible. The visible_rows use the array, but anything
outside the visible rows are just left overs.
Using the bsearch on the entire array causes errors in the search.
It should only use the subset that is visible.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-view-store.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/trace-view-store.c b/trace-view-store.c index df16561..31c702b 100644 --- a/trace-view-store.c +++ b/trace-view-store.c | |||
@@ -1008,24 +1008,29 @@ static TraceViewRecord * | |||
1008 | search_for_record_by_timestamp(TraceViewStore *store, guint64 ts) | 1008 | search_for_record_by_timestamp(TraceViewStore *store, guint64 ts) |
1009 | { | 1009 | { |
1010 | TraceViewRecord key; | 1010 | TraceViewRecord key; |
1011 | TraceViewRecord **rec; | 1011 | TraceViewRecord *rec, **prec; |
1012 | 1012 | ||
1013 | if (!store->actual_rows) | 1013 | if (!store->visible_rows) |
1014 | return NULL; | 1014 | return NULL; |
1015 | 1015 | ||
1016 | if (ts < store->rows[0]->timestamp) | 1016 | if (ts < store->rows[0]->timestamp) |
1017 | return NULL; | 1017 | return NULL; |
1018 | 1018 | ||
1019 | if (ts >= store->rows[store->actual_rows-1]->timestamp) | 1019 | if (ts >= store->rows[store->visible_rows-1]->timestamp) |
1020 | return store->rows[store->actual_rows-1]; | 1020 | return store->rows[store->visible_rows-1]; |
1021 | 1021 | ||
1022 | key.timestamp = ts; | 1022 | key.timestamp = ts; |
1023 | rec = bsearch(&key, store->rows, store->actual_rows - 1, | 1023 | prec = bsearch(&key, store->rows, store->visible_rows - 2, |
1024 | sizeof(store->rows[0]), rows_ts_cmp); | 1024 | sizeof(store->rows[0]), rows_ts_cmp); |
1025 | 1025 | ||
1026 | g_assert(rec != NULL); | 1026 | g_assert(prec != NULL); |
1027 | 1027 | ||
1028 | return *rec; | 1028 | rec = *prec; |
1029 | |||
1030 | if (rec) | ||
1031 | printf("found row rec for %ld at %ld\n", | ||
1032 | ts, rec->timestamp); | ||
1033 | return rec; | ||
1029 | } | 1034 | } |
1030 | 1035 | ||
1031 | gint trace_view_store_get_timestamp_visible_row(TraceViewStore *store, guint64 ts) | 1036 | gint trace_view_store_get_timestamp_visible_row(TraceViewStore *store, guint64 ts) |
@@ -1038,13 +1043,6 @@ gint trace_view_store_get_timestamp_visible_row(TraceViewStore *store, guint64 t | |||
1038 | if (!rec) | 1043 | if (!rec) |
1039 | return 0; | 1044 | return 0; |
1040 | 1045 | ||
1041 | /* Make sure the record is visible */ | ||
1042 | while (rec && !rec->visible) | ||
1043 | rec++; | ||
1044 | |||
1045 | if (!rec) | ||
1046 | return 0; | ||
1047 | |||
1048 | return rec->pos - (store->page - 1) * store->rows_per_page; | 1046 | return rec->pos - (store->page - 1) * store->rows_per_page; |
1049 | } | 1047 | } |
1050 | 1048 | ||
@@ -1067,7 +1065,7 @@ guint64 trace_view_store_get_time_from_row(TraceViewStore *store, gint row) | |||
1067 | 1065 | ||
1068 | row += store->start_row; | 1066 | row += store->start_row; |
1069 | 1067 | ||
1070 | g_return_val_if_fail (row >= 0 && row < store->actual_rows, 0); | 1068 | g_return_val_if_fail (row >= 0 && row < store->visible_rows, 0); |
1071 | 1069 | ||
1072 | return store->rows[row]->timestamp; | 1070 | return store->rows[row]->timestamp; |
1073 | } | 1071 | } |
@@ -1078,7 +1076,7 @@ guint64 trace_view_store_get_offset_from_row(TraceViewStore *store, gint row) | |||
1078 | 1076 | ||
1079 | row += store->start_row; | 1077 | row += store->start_row; |
1080 | 1078 | ||
1081 | g_return_val_if_fail (row >= 0 && row < store->actual_rows, 0); | 1079 | g_return_val_if_fail (row >= 0 && row < store->visible_rows, 0); |
1082 | 1080 | ||
1083 | return store->rows[row]->offset; | 1081 | return store->rows[row]->offset; |
1084 | } | 1082 | } |