]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Add rspamd_min_heap_index helper method
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 10 Apr 2016 12:43:26 +0000 (13:43 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Sun, 10 Apr 2016 12:44:07 +0000 (13:44 +0100)
src/libutil/heap.c
src/libutil/heap.h

index 9bcfd4f1d4bb8110cdf704fdd202c8d33197070a..115b2e6a83f1a4bdf34719ea2144c8e227ef8c4f 100644 (file)
@@ -179,3 +179,12 @@ rspamd_min_heap_destroy (struct rspamd_min_heap *heap)
                g_slice_free1 (sizeof (*heap), heap);
        }
 }
+
+struct rspamd_min_heap_elt*
+rspamd_min_heap_index (struct rspamd_min_heap *heap, guint idx)
+{
+       g_assert (heap != NULL);
+       g_assert (idx >= 0 && idx < heap->ar->len);
+
+       return g_ptr_array_index (heap->ar, idx);
+}
index 20e9209ce3cf146ca4653b787e4a51f1138be5a7..7d6ef4fff2097c7b62aced0e186f37b1a5ab8ce2 100644 (file)
@@ -77,4 +77,13 @@ void rspamd_min_heap_remove_elt (struct rspamd_min_heap *heap,
  */
 void rspamd_min_heap_destroy (struct rspamd_min_heap *heap);
 
+/**
+ * Returns element from the heap with the specified index
+ * @param heap
+ * @param idx
+ * @return
+ */
+struct rspamd_min_heap_elt* rspamd_min_heap_index (struct rspamd_min_heap *heap,
+               guint idx);
+
 #endif /* SRC_LIBUTIL_HEAP_H_ */