From 6c82898225bdd4a6c713317929403d72eab5d1bc Mon Sep 17 00:00:00 2001
From: Abdelrahman Said <said.abdelrahman89@gmail.com>
Date: Sun, 9 Jun 2024 18:25:37 +0100
Subject: [PATCH] Update dstr to remove MSVC warnings

---
 src/strings/dstr/dstr.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

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 <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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);