From: Vsevolod Stakhov Date: Sun, 10 Apr 2016 12:43:26 +0000 (+0100) Subject: [Minor] Add rspamd_min_heap_index helper method X-Git-Tag: 1.2.3~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=db6676684a4a8f961e8ada8f627d4b178e0e1669;p=thirdparty%2Frspamd.git [Minor] Add rspamd_min_heap_index helper method --- diff --git a/src/libutil/heap.c b/src/libutil/heap.c index 9bcfd4f1d4..115b2e6a83 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 20e9209ce3..7d6ef4fff2 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_ */