]> mj.ucw.cz Git - libucw.git/commitdiff
Heap: Adjust callers
authorMartin Mares <mj@ucw.cz>
Sun, 21 Oct 2012 15:11:58 +0000 (17:11 +0200)
committerMartin Mares <mj@ucw.cz>
Sun, 21 Oct 2012 15:11:58 +0000 (17:11 +0200)
ucw/mainloop.c
ucw/sorter/debug/retros.c
ucw/workqueue.c

index b2b07c5082476bedbdc023e094f49f6feb02a28b..1fee8b011644b639778c6467604a650aa557e4a5 100644 (file)
@@ -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);
        }
     }
 }
index 25423cc59e11b2ae36300bb1bb472e0805ccd0da..7325de7529721d1af36c99a3706fd9b1fc8009a1 100644 (file)
@@ -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
 }
 
index 732160bba65553a277403f6cee6159543283baad..530e7789f1c8c2573f37f4da8569bc9313e7a692 100644 (file)
@@ -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;