]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
pool: Use bool return type
authorJeff Lucovsky <jlucovsky@oisf.net>
Sat, 3 Jun 2023 14:04:33 +0000 (10:04 -0400)
committerVictor Julien <vjulien@oisf.net>
Fri, 9 Jun 2023 08:37:09 +0000 (10:37 +0200)
Issue: 5563

This commit changes PoolDataPreAllocated to return a bool instead of an
int.

src/util-pool.c

index b8fe4abb4fbceb058155214d3c34f2d7b331786d..26d6480099e92eb4090cfdc105b5784a617d1270 100644 (file)
@@ -54,14 +54,14 @@ static int PoolMemset(void *pitem, void *initdata)
 
 /**
  * \brief Check if data is preallocated
- * \retval 0 if not inside the prealloc'd block, 1 if inside */
-static int PoolDataPreAllocated(Pool *p, void *data)
+ * \retval false if not inside the prealloc'd block, true if inside */
+static bool PoolDataPreAllocated(Pool *p, void *data)
 {
     ptrdiff_t delta = data - p->data_buffer;
     if ((delta < 0) || (delta > p->data_buffer_size)) {
-        return 0;
+        return false;
     }
-    return 1;
+    return true;
 }
 
 /** \brief Init a Pool
@@ -233,7 +233,7 @@ void PoolFree(Pool *p)
         p->alloc_stack = pb->next;
         if (p->Cleanup)
             p->Cleanup(pb->data);
-        if (PoolDataPreAllocated(p, pb->data) == 0) {
+        if (!PoolDataPreAllocated(p, pb->data)) {
             if (p->Free)
                 p->Free(pb->data);
             else
@@ -251,7 +251,7 @@ void PoolFree(Pool *p)
         if (pb->data!= NULL) {
             if (p->Cleanup)
                 p->Cleanup(pb->data);
-            if (PoolDataPreAllocated(p, pb->data) == 0) {
+            if (!PoolDataPreAllocated(p, pb->data)) {
                 if (p->Free)
                     p->Free(pb->data);
                 else
@@ -350,7 +350,7 @@ void PoolReturn(Pool *p, void *data)
         if (p->Cleanup != NULL) {
             p->Cleanup(data);
         }
-        if (PoolDataPreAllocated(p, data) == 0) {
+        if (!PoolDataPreAllocated(p, data)) {
             if (p->Free)
                 p->Free(data);
             else