dovecot-1.1: Fixed removing last item from priority queue.
dovecot at dovecot.org
dovecot at dovecot.org
Fri Feb 29 03:28:19 EET 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/8e65f6755843
changeset: 7302:8e65f6755843
user: Timo Sirainen <tss at iki.fi>
date: Fri Feb 29 03:31:06 2008 +0200
description:
Fixed removing last item from priority queue.
diffstat:
1 file changed, 5 insertions(+), 3 deletions(-)
src/lib/priorityq.c | 8 +++++---
diffs (28 lines):
diff -r c75b2e1fa5a2 -r 8e65f6755843 src/lib/priorityq.c
--- a/src/lib/priorityq.c Thu Feb 28 06:29:43 2008 +0200
+++ b/src/lib/priorityq.c Fri Feb 29 03:31:06 2008 +0200
@@ -66,11 +66,13 @@ heap_item_bubble_up(struct priorityq *pq
heap_item_bubble_up(struct priorityq *pq, unsigned int idx)
{
struct priorityq_item **items;
- unsigned int parent_idx;
+ unsigned int parent_idx, count;
- items = array_idx_modifiable(&pq->items, 0);
+ items = array_get_modifiable(&pq->items, &count);
while (idx > 0) {
parent_idx = PARENT_IDX(idx);
+
+ i_assert(idx < count);
if (pq->cmp_callback(items[idx], items[parent_idx]) >= 0)
break;
@@ -124,7 +126,7 @@ static void priorityq_remove_idx(struct
heap_items_swap(items, idx, count);
array_delete(&pq->items, count, 1);
- if (count > 0) {
+ if (count > 0 && idx != count) {
if (idx > 0)
idx = heap_item_bubble_up(pq, idx);
heap_item_bubble_down(pq, idx);
More information about the dovecot-cvs
mailing list