Was using XREALLOC() and then free(). instant "memleaks".
Signed-off-by: Christian Hopps <chopps@labn.net>
#include "darr.h"
#include "memory.h"
-DEFINE_MTYPE_STATIC(LIB, DARR, "Dynamic Array");
+DEFINE_MTYPE(LIB, DARR, "Dynamic Array");
static uint _msb(uint count)
{
* - 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;
#define darr_free(A) \
do { \
if ((A)) { \
- free(_darr_meta(A)); \
+ void *__ptr = _darr_meta(A); \
+ XFREE(MTYPE_DARR, __ptr); \
(A) = NULL; \
} \
} while (0)