Annotate prio heap likely branch
[babeltrace.git] / include / babeltrace / prio_heap.h
index 51cdac56c26d693a9a655f2318c8b81d3e2c67b8..b3e2491e519b9be5e86409b54f89a3985397cafb 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include <unistd.h>
+#include <babeltrace/babeltrace-internal.h>
 
 struct ptr_heap {
        size_t len, alloc_len;
@@ -28,6 +29,15 @@ struct ptr_heap {
        int (*gt)(void *a, void *b);
 };
 
+#ifdef DEBUG_HEAP
+void check_heap(const struct ptr_heap *heap);
+#else
+static inline
+void check_heap(const struct ptr_heap *heap)
+{
+}
+#endif
+
 /**
  * heap_maximum - return the largest element in the heap
  * @heap: the heap to be operated on
@@ -37,7 +47,8 @@ struct ptr_heap {
  */
 static inline void *heap_maximum(const struct ptr_heap *heap)
 {
-       return heap->len ? heap->ptrs[0] : NULL;
+       check_heap(heap);
+       return likely(heap->len) ? heap->ptrs[0] : NULL;
 }
 
 /**
This page took 0.024067 seconds and 4 git commands to generate.