diff --git a/src/strings/dstr/dstr.c b/src/strings/dstr/dstr.c index b7517f4..2e2ea78 100644 --- a/src/strings/dstr/dstr.c +++ b/src/strings/dstr/dstr.c @@ -1,6 +1,7 @@ #include "dstr.h" #include "aliases.h" #include "mem_arena.h" +#include "platform.h" #include #include #include @@ -13,7 +14,12 @@ struct dstr { u64 capacity; u64 size; + +#ifdef WAPP_PLATFORM_WINDOWS + char *buf; +#else char buf[]; +#endif // WAPP_PLATFORM_WINDOWS }; String *wapp_dstr_with_capacity(u64 capacity, Arena *arena) { @@ -97,8 +103,19 @@ StringUpdate wapp_dstr_concat(String **dst, const char *src, Arena *arena) { u64 new_length = (*dst)->size + src_length; +#ifdef WAPP_PLATFORM_WINDOWS + char *str = + wapp_mem_util_alloc(NULL, new_length + 1, WAPP_MEM_ACCESS_READ_WRITE, + WAPP_MEM_ALLOC_RESERVE | WAPP_MEM_ALLOC_COMMIT, + WAPP_MEM_INIT_INITIALISED); + + if (!str) { + return (StringUpdate){.updated = false, .str = *dst}; + } +#else char str[new_length + 1]; memset(str, 0, new_length + 1); +#endif strncpy(str, (*dst)->buf, (*dst)->size); strncat(str, src, new_length + 1 - (*dst)->size);