aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-10 13:43:26 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-04-10 13:44:07 +0100
commitdb6676684a4a8f961e8ada8f627d4b178e0e1669 (patch)
treeaba2f1662165e232b661fbaf3d86090b915527e8
parentef763f948579fa1b3d227df571688896c2a900e3 (diff)
downloadrspamd-db6676684a4a8f961e8ada8f627d4b178e0e1669.tar.gz
rspamd-db6676684a4a8f961e8ada8f627d4b178e0e1669.zip
[Minor] Add rspamd_min_heap_index helper method
-rw-r--r--src/libutil/heap.c9
-rw-r--r--src/libutil/heap.h9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/libutil/heap.c b/src/libutil/heap.c
index 9bcfd4f1d..115b2e6a8 100644
--- a/src/libutil/heap.c
+++ b/src/libutil/heap.c
@@ -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);
+}
diff --git a/src/libutil/heap.h b/src/libutil/heap.h
index 20e9209ce..7d6ef4fff 100644
--- a/src/libutil/heap.h
+++ b/src/libutil/heap.h
@@ -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_ */