diff options
Diffstat (limited to 'src/libutil/heap.c')
-rw-r--r-- | src/libutil/heap.c | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/libutil/heap.c b/src/libutil/heap.c index ba1b44793..9bcfd4f1d 100644 --- a/src/libutil/heap.c +++ b/src/libutil/heap.c @@ -138,7 +138,6 @@ rspamd_min_heap_update_elt (struct rspamd_min_heap *heap, g_assert (heap != NULL); g_assert (elt->idx > 0 && elt->idx <= heap->ar->len); - oldpri = elt->pri; elt->pri = npri; @@ -153,6 +152,26 @@ rspamd_min_heap_update_elt (struct rspamd_min_heap *heap, } void +rspamd_min_heap_remove_elt (struct rspamd_min_heap *heap, + struct rspamd_min_heap_elt *elt) +{ + struct rspamd_min_heap_elt *first; + + g_assert (heap != NULL); + g_assert (elt->idx > 0 && elt->idx <= heap->ar->len); + + first = g_ptr_array_index (heap->ar, 0); + + if (elt != first) { + elt->pri = first->pri - 1; + rspamd_min_heap_swim (heap, elt); + } + + /* Now the desired element is on the top of queue */ + (void)rspamd_min_heap_pop (heap); +} + +void rspamd_min_heap_destroy (struct rspamd_min_heap *heap) { if (heap) { |