]> mj.ucw.cz Git - libucw.git/blobdiff - lib/heap.h
Removed xprintf() -- it was very ugly and its only raison d'etre was
[libucw.git] / lib / heap.h
index 268cc2572cd8d3ad855464d7c8a6e2a5b41dead7..a70fb2cd8c806551fe87b995e013913a3f581e4d 100644 (file)
@@ -2,6 +2,9 @@
  *     Sherlock Library -- Universal Heap Macros
  *
  *     (c) 2001 Martin Mares <mj@ucw.cz>
  *     Sherlock Library -- Universal Heap Macros
  *
  *     (c) 2001 Martin Mares <mj@ucw.cz>
+ *
+ *     This software may be freely distributed and used according to the terms
+ *     of the GNU Lesser General Public License.
  */
 
 #define HEAP_BUBBLE_DOWN_J(heap,num,less,swap)                                         \
  */
 
 #define HEAP_BUBBLE_DOWN_J(heap,num,less,swap)                                         \
@@ -71,9 +74,9 @@
   do {                                                                                 \
     uns j, l, u;                                                                       \
     type x;                                                                            \
   do {                                                                                 \
     uns j, l, u;                                                                       \
     type x;                                                                            \
-    swap(heap,pos,num,x);                                                              \
-    num--;                                                                             \
     j = pos;                                                                           \
     j = pos;                                                                           \
+    swap(heap,j,num,x);                                                                        \
+    num--;                                                                             \
     if (less(heap[j], heap[num+1]))                                                    \
       HEAP_BUBBLE_UP_J(heap,num,less,swap)                                             \
     else                                                                               \
     if (less(heap[j], heap[num+1]))                                                    \
       HEAP_BUBBLE_UP_J(heap,num,less,swap)                                             \
     else                                                                               \