]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/basic/prioq.c
tree-wide: use mfree more
[thirdparty/systemd.git] / src / basic / prioq.c
index 69ec45d97e067e0d517198530dd1e28b81bc550e..4570b8e4baab44afa49ef667257833be54568fde 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
  * The underlying algorithm used in this implementation is a Heap.
  */
 
-#include "util.h"
+#include <errno.h>
+#include <stdlib.h>
+
+#include "alloc-util.h"
+#include "hashmap.h"
 #include "prioq.h"
 
 struct prioq_item {
@@ -60,9 +62,7 @@ Prioq* prioq_free(Prioq *q) {
                 return NULL;
 
         free(q->items);
-        free(q);
-
-        return NULL;
+        return mfree(q);
 }
 
 int prioq_ensure_allocated(Prioq **q, compare_func_t compare_func) {
@@ -111,7 +111,7 @@ static unsigned shuffle_up(Prioq *q, unsigned idx) {
 
                 k = (idx-1)/2;
 
-                if (q->compare_func(q->items[k].data, q->items[idx].data) < 0)
+                if (q->compare_func(q->items[k].data, q->items[idx].data) <= 0)
                         break;
 
                 swap(q, idx, k);