From: Alan T. DeKok Date: Thu, 22 Jun 2023 19:52:03 +0000 (-0400) Subject: define and use macro for invalid entries X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31fe14f4cbde1624724458796a03a487cd14c453;p=thirdparty%2Ffreeradius-server.git define and use macro for invalid entries --- diff --git a/src/lib/util/heap.c b/src/lib/util/heap.c index 3e915cd6563..5762a0b75f9 100644 --- a/src/lib/util/heap.c +++ b/src/lib/util/heap.c @@ -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. diff --git a/src/lib/util/heap.h b/src/lib/util/heap.h index ea90c9bfa8b..5c615f0e4fe 100644 --- a/src/lib/util/heap.h +++ b/src/lib/util/heap.h @@ -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