Fix: Restore heap for SEEK_BEGIN
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 2 Aug 2012 21:45:54 +0000 (17:45 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Thu, 2 Aug 2012 21:45:54 +0000 (17:45 -0400)
We don't know in which state the heap is when we call a SEEK_BEGIN, so
we need to clear it and populate it when all the filestreams are in
place.

Fixes: #319
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lib/iterator.c

index 65429a890e68b6b3cb84fabb421f54c1d3a991dc..60e877ec71024d4ccf1a71c7eaea939e35c81331 100644 (file)
@@ -276,6 +276,11 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos)
                return 0;
        case BT_SEEK_BEGIN:
                tc = iter->ctx->tc;
+               heap_free(iter->stream_heap);
+               ret = heap_init(iter->stream_heap, 0, stream_compare);
+               if (ret < 0)
+                       goto error;
+
                for (i = 0; i < tc->array->len; i++) {
                        struct ctf_trace *tin;
                        struct trace_descriptor *td_read;
@@ -310,6 +315,9 @@ int bt_iter_set_pos(struct bt_iter *iter, const struct bt_iter_pos *iter_pos)
                                        if (ret != 0 && ret != EOF) {
                                                goto error;
                                        }
+                                       ret = heap_insert(iter->stream_heap, file_stream);
+                                       if (ret)
+                                               goto error;
                                }
                        }
                }
This page took 0.033546 seconds and 4 git commands to generate.