]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: darr needs to use memory.h for both alloc and free 14772/head
authorChristian Hopps <chopps@labn.net>
Sat, 11 Nov 2023 19:27:22 +0000 (20:27 +0100)
committerChristian Hopps <chopps@labn.net>
Sat, 11 Nov 2023 19:30:02 +0000 (20:30 +0100)
Was using XREALLOC() and then free(). instant "memleaks".

Signed-off-by: Christian Hopps <chopps@labn.net>
lib/darr.c
lib/darr.h

index bef51b8fc4a539bab63a6dfac5c45029a711bfed..282e0dc5dc2738409b4754a16a8bafa8cea18cbc 100644 (file)
@@ -9,7 +9,7 @@
 #include "darr.h"
 #include "memory.h"
 
-DEFINE_MTYPE_STATIC(LIB, DARR, "Dynamic Array");
+DEFINE_MTYPE(LIB, DARR, "Dynamic Array");
 
 static uint _msb(uint count)
 {
index ca46fb30543fd20d2d1ac59aadb50624ce171aa5..d78d97d5f3640f14a14039b34e303b4a10e1af4f 100644 (file)
@@ -35,6 +35,9 @@
  * - DAs will never have capacity 0 unless they are NULL pointers.
  */
 #include <zebra.h>
+#include "memory.h"
+
+DECLARE_MTYPE(DARR);
 
 struct darr_metadata {
        uint len;
@@ -111,7 +114,8 @@ void *__darr_resize(void *a, uint count, size_t esize);
 #define darr_free(A)                                                           \
        do {                                                                   \
                if ((A)) {                                                     \
-                       free(_darr_meta(A));                                   \
+                       void *__ptr = _darr_meta(A);                           \
+                       XFREE(MTYPE_DARR, __ptr);                              \
                        (A) = NULL;                                            \
                }                                                              \
        } while (0)