From db6676684a4a8f961e8ada8f627d4b178e0e1669 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Sun, 10 Apr 2016 13:43:26 +0100 Subject: [PATCH] [Minor] Add rspamd_min_heap_index helper method --- src/libutil/heap.c | 9 +++++++++ src/libutil/heap.h | 9 +++++++++ 2 files changed, 18 insertions(+) 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_ */ -- 2.39.5