\r
// NOTE: To use c_da_append() the Dynamic-Array struct should be defined using\r
// DEFINE_DYNAMIC_ARRAY or have the same members as below!\r
-#define DEFINE_DYNAMIC_ARRAY(struct_name, elm_type) typedef struct {\\r
- elm_type *items;\\r
- size_t count;\\r
- size_t capacity;\\r
- }\r
+// NOTE!!!: We actually don't want this since this makes the user want to \r
+// use this macro to define dynamic arrays. But the user might want extra fields\r
+// in the struct; So we recommend defining da structs manually like:\r
+// ```C\r
+// typedef struct {\r
+// <item-type> items;\r
+// size_t count;\r
+// size_t capacity;\r
+// [extra fields...];\r
+// }\r
+// ```\r
+// #define DEFINE_DYNAMIC_ARRAY(struct_name, elm_type) typedef struct {\\r
+// elm_type *items;\\r
+// size_t count;\\r
+// size_t capacity;\\r
+// }\r
\r
#define c_DYNAMIC_ARRAY_INITIAL_CAPACITY (sizeof(size_t))\r
\r
#define c_da_append(da, elm) do {\\r
if ((da).items == NULL) {\\r
- (da).capacity = DYNAMIC_ARRAY_INITIAL_CAPACITY;\\r
+ (da).capacity = c_DYNAMIC_ARRAY_INITIAL_CAPACITY;\\r
(da).count = 0;\\r
(da).items = C_MALLOC(sizeof(elm) * (da).capacity);\\r
}\\r
if ((da).count + 1 > (da).capacity) {\\r
(da).capacity *= 2;\\r
- if (DEBUG) log_info("%s realloced!", #da);\\r
- ASSERT(C_REALLOC((da).items, (da).capacity * sizeof(*(da).items)) != NULL, "TODO: Log error instead of asserting");\\r
+ c_ASSERT(C_REALLOC((da).items, (da).capacity * sizeof(*(da).items)) != NULL, "TODO: Log error instead of asserting");\\r
}\\r
(da).items[(da).count++] = elm;\\r
} while (0)\r