From 7cc9c555b0ef228f93a9f06b7c4b126b05688f79 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 21 Oct 2012 17:11:58 +0200 Subject: [PATCH] Heap: Adjust callers --- ucw/mainloop.c | 8 ++++---- ucw/sorter/debug/retros.c | 4 ++-- ucw/workqueue.c | 5 ++--- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/ucw/mainloop.c b/ucw/mainloop.c index b2b07c50..1fee8b01 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -260,13 +260,13 @@ timer_add(struct main_timer *tm, timestamp_t expires) { tm->expires = expires; tm->index = num_timers + 1; - *GARY_PUSH(m->timer_table, 1) = tm; - HEAP_INSERT(struct main_timer *, m->timer_table, tm->index, MAIN_TIMER_LESS, MAIN_TIMER_SWAP); + GARY_RESIZE(m->timer_table, num_timers + 2); + HEAP_INSERT(struct main_timer *, m->timer_table, tm->index, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm); } else { tm->expires = expires; - HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index); + HEAP_INCREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm); } } else if (tm->expires > expires) @@ -282,7 +282,7 @@ timer_add(struct main_timer *tm, timestamp_t expires) else { tm->expires = expires; - HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index); + HEAP_DECREASE(struct main_timer *, m->timer_table, num_timers, MAIN_TIMER_LESS, MAIN_TIMER_SWAP, tm->index, tm); } } } diff --git a/ucw/sorter/debug/retros.c b/ucw/sorter/debug/retros.c index 25423cc5..7325de75 100644 --- a/ucw/sorter/debug/retros.c +++ b/ucw/sorter/debug/retros.c @@ -623,7 +623,7 @@ static void heapsort(void) HEAP_INIT(struct elt, heap, n, H_LESS, HEAP_SWAP); uns nn = n; while (nn) - HEAP_DELMIN(struct elt, heap, nn, H_LESS, HEAP_SWAP); + HEAP_DELETE_MIN(struct elt, heap, nn, H_LESS, HEAP_SWAP); #undef H_LESS } @@ -634,7 +634,7 @@ static void heapsort_ind(void) HEAP_INIT(struct elt *, heap, n, H_LESS, HEAP_SWAP); uns nn = n; while (nn) - HEAP_DELMIN(struct elt *, heap, nn, H_LESS, HEAP_SWAP); + HEAP_DELETE_MIN(struct elt *, heap, nn, H_LESS, HEAP_SWAP); #undef H_LESS } diff --git a/ucw/workqueue.c b/ucw/workqueue.c index 732160bb..530e7789 100644 --- a/ucw/workqueue.c +++ b/ucw/workqueue.c @@ -131,8 +131,7 @@ raw_queue_put(struct raw_queue *q, struct work *w) q->pri_heap = xrealloc(old_heap, (q->heap_max + 1) * sizeof(struct work *)); } struct work **heap = q->pri_heap; - heap[++q->heap_cnt] = w; - HEAP_INSERT(struct work *, heap, q->heap_cnt, PRI_LESS, HEAP_SWAP); + HEAP_INSERT(struct work *, heap, q->heap_cnt, PRI_LESS, HEAP_SWAP, w); } pthread_mutex_unlock(&q->queue_mutex); sem_post(q->queue_sem); @@ -153,7 +152,7 @@ raw_queue_do_get(struct raw_queue *q) { struct work **heap = q->pri_heap; w = heap[1]; - HEAP_DELMIN(struct work *, heap, q->heap_cnt, PRI_LESS, HEAP_SWAP); + HEAP_DELETE_MIN(struct work *, heap, q->heap_cnt, PRI_LESS, HEAP_SWAP); } pthread_mutex_unlock(&q->queue_mutex); return w; -- 2.39.2