Skip to content

Commit

Permalink
Merge pull request #80 from ratchetfreak/patch-1
Browse files Browse the repository at this point in the history
fix nob_da_append_many in nob.h
  • Loading branch information
rexim authored Feb 21, 2024
2 parents 62aa058 + 7cec0d7 commit 0fa030b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/nob.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,18 @@ Nob_File_Type nob_get_file_type(const char *path);
// Append several items to a dynamic array
#define nob_da_append_many(da, new_items, new_items_count) \
do { \
if ((da)->count + new_items_count > (da)->capacity) { \
if ((da)->count + (new_items_count) > (da)->capacity) { \
if ((da)->capacity == 0) { \
(da)->capacity = NOB_DA_INIT_CAP; \
} \
while ((da)->count + new_items_count > (da)->capacity) { \
while ((da)->count + (new_items_count) > (da)->capacity) { \
(da)->capacity *= 2; \
} \
(da)->items = NOB_REALLOC((da)->items, (da)->capacity*sizeof(*(da)->items)); \
NOB_ASSERT((da)->items != NULL && "Buy more RAM lol"); \
} \
memcpy((da)->items + (da)->count, new_items, new_items_count*sizeof(*(da)->items)); \
(da)->count += new_items_count; \
memcpy((da)->items + (da)->count, (new_items), (new_items_count)*sizeof(*(da)->items)); \
(da)->count += (new_items_count); \
} while (0)

typedef struct {
Expand Down

0 comments on commit 0fa030b

Please sign in to comment.