binary search fix
authorcompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 4 Aug 2005 23:22:35 +0000 (23:22 +0000)
committercompudj <compudj@04897980-b3bd-0310-b5e0-8ef037075253>
Thu, 4 Aug 2005 23:22:35 +0000 (23:22 +0000)
git-svn-id: http://ltt.polymtl.ca/svn@1005 04897980-b3bd-0310-b5e0-8ef037075253

ltt/branches/poly/ltt-newlib/tracefile.c

index e0f88554ee87e065185a439535e122e32f6bf729..65f618b8f2babf46f1f069ccc2b02439d0b17e34 100644 (file)
@@ -1177,7 +1177,20 @@ void ltt_tracefile_seek_time(LttTracefile *tf, LttTime time)
       g_error("Can not map block");
       goto fail;
     }
-    if(ltt_time_compare(time, tf->buffer.start.timestamp) < 0) {
+    if(high == low) {
+      /* We cannot divide anymore : this is what would happen if the time
+       * requested was exactly between two consecutive buffers'end and start 
+       * timestamps. This is also what would happend if we didn't deal with out
+       * of span cases prior in this function. */
+      /* The event is right in the buffer!
+       * (or in the next buffer first event) */
+      while(1) {
+        ltt_tracefile_read(tf);
+        if(ltt_time_compare(time, tf->event.event_time) >= 0)
+          break;
+      }
+
+    } if(ltt_time_compare(time, tf->buffer.start.timestamp) < 0) {
       /* go to lower part */
       high = block_num;
     } else if(ltt_time_compare(time, tf->buffer.end.timestamp) > 0) {
This page took 0.024809 seconds and 4 git commands to generate.