summaryrefslogtreecommitdiff
path: root/lib/darr.h
diff options
context:
space:
mode:
authorChristian Hopps <chopps@labn.net>2023-11-11 20:27:22 +0100
committerChristian Hopps <chopps@labn.net>2023-11-11 20:30:02 +0100
commita6c8e08ecdbff443cde703a6f360cbe585f0a6ff (patch)
tree62480d43ba4aae7f861b521aac8a9cd163a6a9ab /lib/darr.h
parent19bcca4f2e9a3ee3c8cc16608dcf303241bbf014 (diff)
lib: darr needs to use memory.h for both alloc and free
Was using XREALLOC() and then free(). instant "memleaks". Signed-off-by: Christian Hopps <chopps@labn.net>
Diffstat (limited to 'lib/darr.h')
-rw-r--r--lib/darr.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/darr.h b/lib/darr.h
index ca46fb3054..d78d97d5f3 100644
--- a/lib/darr.h
+++ b/lib/darr.h
@@ -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)