]> www.git.momoyon.org Git - commonlib.git/commitdiff
Fix da_append.
authorahmedsamyh <ahmedsamyh10@gmail.com>
Fri, 21 Feb 2025 14:06:16 +0000 (19:06 +0500)
committerahmedsamyh <ahmedsamyh10@gmail.com>
Fri, 21 Feb 2025 14:06:16 +0000 (19:06 +0500)
commonlib.h

index 3acd0eb75fd952ba72c84d0d506f31ae79153da9..1629744adec710c2905613b2923cbadfdc6fd27c 100644 (file)
@@ -115,9 +115,10 @@ typedef struct c_Arena c_Arena;
                        (da).count = 0;\\r
                        (da).items = C_MALLOC(sizeof(elm) * (da).capacity);\\r
                }\\r
-               if ((da).count + 1 > (da).capacity) {\\r
+               if ((da).count >= (da).capacity) {\\r
                        (da).capacity *= 2;\\r
-                       c_ASSERT(C_REALLOC((da).items, (da).capacity * sizeof(*(da).items)) != NULL, "TODO: Log error instead of asserting");\\r
+                        (da).items = C_REALLOC((da).items, (da).capacity * sizeof(elm));\\r
+                       c_ASSERT((da).items != NULL, "TODO: Log error instead of asserting");\\r
                }\\r
                (da).items[(da).count++] = elm;\\r
        } while (0)\r