Merge pull request #14772 from LabNConsulting/fix-darr-memory-acct

This commit is contained in:
Igor Ryzhov 2023-11-13 05:47:36 +02:00 committed by GitHub
commit 5dcd9f65e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View 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)
{

View 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)