summaryrefslogtreecommitdiffstats
path: root/lib/darr.c
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas@opensourcerouting.org>2023-10-03 09:34:27 +0200
committerGitHub <noreply@github.com>2023-10-03 09:34:27 +0200
commit4d087a71d3a524dd6ec17fbdf1d2b39b1569ae5f (patch)
tree1e325b773d7d1e5e09183b1e1a33984f5703acea /lib/darr.c
parentMerge pull request #14519 from anlancs/fix/doc-zebra-values (diff)
parentlib: use XREALLOC over realloc avoid coverity warning (diff)
downloadfrr-4d087a71d3a524dd6ec17fbdf1d2b39b1569ae5f.tar.xz
frr-4d087a71d3a524dd6ec17fbdf1d2b39b1569ae5f.zip
Merge pull request #14508 from LabNConsulting/chopps/darr-use-frrmemfunc
lib: use XREALLOC over realloc avoid coverity warning
Diffstat (limited to 'lib/darr.c')
-rw-r--r--lib/darr.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/lib/darr.c b/lib/darr.c
index f0ef5c90b..bef51b8fc 100644
--- a/lib/darr.c
+++ b/lib/darr.c
@@ -7,8 +7,9 @@
*/
#include <zebra.h>
#include "darr.h"
+#include "memory.h"
-void __dar_resize(void **a, uint count, size_t esize);
+DEFINE_MTYPE_STATIC(LIB, DARR, "Dynamic Array");
static uint _msb(uint count)
{
@@ -56,15 +57,12 @@ void *__darr_resize(void *a, uint count, size_t esize)
uint ncount = darr_next_count(count, esize);
size_t osz = (a == NULL) ? 0 : darr_size(darr_cap(a), esize);
size_t sz = darr_size(ncount, esize);
- struct darr_metadata *dm = realloc(a ? _darr_meta(a) : NULL, sz);
- /* do *not* use a */
+ struct darr_metadata *dm = XREALLOC(MTYPE_DARR,
+ a ? _darr_meta(a) : NULL, sz);
- assert(dm);
if (sz > osz)
memset((char *)dm + osz, 0, sz - osz);
-
dm->cap = ncount;
-
return (void *)(dm + 1);
}