]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
define and use macro for invalid entries
authorAlan T. DeKok <aland@freeradius.org>
Thu, 22 Jun 2023 19:52:03 +0000 (15:52 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 22 Jun 2023 19:52:03 +0000 (15:52 -0400)
src/lib/util/heap.c
src/lib/util/heap.h

index 3e915cd65634c28314d8adee8ed2e0b8557f7eea..5762a0b75f903c3778538bacede256c316fe3cf6 100644 (file)
@@ -203,7 +203,7 @@ int fr_heap_insert(fr_heap_t **hp, void *data)
 
 static inline CC_HINT(always_inline) void fr_heap_bubble(fr_heap_t *h, fr_heap_index_t child)
 {
-       if (!fr_cond_assert(child > 0)) return;
+       if (!fr_cond_assert(child != FR_HEAP_INDEX_INVALID)) return;
 
        /*
         *      Bubble up the element.
index ea90c9bfa8be6b080460563ae031c6745e3a1678..5c615f0e4fee73795140048ce5b2eac2f3fd941f 100644 (file)
@@ -80,6 +80,8 @@ typedef struct {
 typedef unsigned int fr_heap_index_t;
 typedef unsigned int fr_heap_iter_t;
 
+#define FR_HEAP_INDEX_INVALID (0)
+
 /** How many talloc headers need to be pre-allocated for a heap
  */
 #define FR_HEAP_TALLOC_HEADERS 2
@@ -121,7 +123,7 @@ fr_heap_t   *_fr_heap_alloc(TALLOC_CTX *ctx, fr_heap_cmp_t cmp, char const *talloc
  */
 static inline bool fr_heap_entry_inserted(fr_heap_index_t heap_idx)
 {
-       return (heap_idx > 0);
+       return (heap_idx != FR_HEAP_INDEX_INVALID);
 }
 
 /** Return the item from the top of the heap but don't pop it