From de1722fc302faab1666a9920f7fbc0c6fbcab2ea Mon Sep 17 00:00:00 2001 From: ahmedsamyh Date: Fri, 21 Feb 2025 19:06:16 +0500 Subject: [PATCH] Fix da_append. --- commonlib.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/commonlib.h b/commonlib.h index 3acd0eb..1629744 100644 --- a/commonlib.h +++ b/commonlib.h @@ -115,9 +115,10 @@ typedef struct c_Arena c_Arena; (da).count = 0;\ (da).items = C_MALLOC(sizeof(elm) * (da).capacity);\ }\ - if ((da).count + 1 > (da).capacity) {\ + if ((da).count >= (da).capacity) {\ (da).capacity *= 2;\ - c_ASSERT(C_REALLOC((da).items, (da).capacity * sizeof(*(da).items)) != NULL, "TODO: Log error instead of asserting");\ + (da).items = C_REALLOC((da).items, (da).capacity * sizeof(elm));\ + c_ASSERT((da).items != NULL, "TODO: Log error instead of asserting");\ }\ (da).items[(da).count++] = elm;\ } while (0) -- 2.39.5