From 436286343a568abab389b196fc767423ada0b608 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Tue, 16 Jun 2026 14:50:43 -0400 Subject: [PATCH 01/21] gate typeof --- src/utils.h | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/utils.h b/src/utils.h index 56503aebd..d61c27434 100644 --- a/src/utils.h +++ b/src/utils.h @@ -10,15 +10,22 @@ #include "real_type.h" +#if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)) \ + || defined(__GNUC__) || defined(__clang__) || defined(__TINYC__) + #define TYPEOF(x) typeof(x) +#else + #define TYPEOF(x) long long +#endif + #define forEach(type, item, array, count) \ - for (typeof(count) item##_i_ = 0; item##_i_ < (count); item##_i_++) \ + for (TYPEOF(count) item##_i_ = 0; item##_i_ < (count); ++item##_i_) \ for (type* item = &(array)[item##_i_]; item; item = NULL) #define forEachIndexed(type, item, index, array, count) \ - for (typeof(count) index = 0; index < (count); index++) \ + for (TYPEOF(count) index = 0; index < (count); ++index) \ for (type* item = &(array)[index]; item; item = NULL) -#define repeat(n, it) for (typeof(n) it = 0; it < (n); ++it) +#define repeat(n, it) for (TYPEOF(n) it = 0; it < (n); ++it) #define require(condition) \ do { \ @@ -48,17 +55,8 @@ static inline void requireMessageFormatted(const char *file, int line, bool cond abort(); } -#define requireNotNull(ptr) ({ \ -typeof(ptr) _val = (ptr); \ -if (_val == NULL) { \ -fprintf(stderr, "%s:%d: requireNotNull failed: '%s'\n", __FILE__, __LINE__, #ptr); \ -abort(); \ -} \ -_val; \ -}) - #define requireNotNullMessage(ptr, msg) ({ \ -typeof(ptr) _val = (ptr); \ +void *_val = (ptr); \ if (_val == NULL) { \ fprintf(stderr, "%s:%d: requireNotNull failed: %s\n", __FILE__, __LINE__, (msg)); \ abort(); \ @@ -66,6 +64,8 @@ abort(); \ _val; \ }) +#define requireNotNull(ptr) requireNotNullMessage(ptr, #ptr) + // Safe allocation macros - check for nullptr and abort with file/line info #define safeMalloc(size) ({ \ void* _ptr = malloc(size); \ From 8f0c9f58577436ece850bcf05d95881d8b57e40e Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Tue, 16 Jun 2026 14:54:29 -0400 Subject: [PATCH 02/21] gate noinline Co-authored-by: Serg One Zero --- src/common.h | 8 ++++++++ src/vm.c | 6 +++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/common.h b/src/common.h index 9c5949bf2..9f3c17ae7 100644 --- a/src/common.h +++ b/src/common.h @@ -42,6 +42,14 @@ #define ALIGN(x) #endif +#if defined(__GNUC__) || defined(__TINYC__) + #define NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) && _MSC_VER >= 1400 // VS2005 or later + #define NOINLINE __declspec(noinline) +#else + #define NOINLINE +#endif + #if defined(__GNUC__) || defined(__clang__) #if defined(__x86_64__) || defined(__i386__) #define YIELD() __asm__ volatile("rep; nop" : : : "memory") diff --git a/src/vm.c b/src/vm.c index 6b27604fc..8d0018fb6 100644 --- a/src/vm.c +++ b/src/vm.c @@ -850,7 +850,7 @@ static void writeSingleInstanceVariable(VMContext* ctx, Instance* inst, Variable } // Force out-of-line so the OP_POP fast path in executeLoop doesn't inline this, because we already have an "optimized" version for common writes -__attribute__((noinline)) +NOINLINE static void resolveVariableWrite(VMContext* ctx, int32_t instanceType, uint32_t varRef, RValue val) { Variable* varDef = resolveVarDef(ctx, varRef); @@ -1468,7 +1468,7 @@ static void handlePopz(VMContext* ctx) { RValue_free(&val); } -__attribute__((noinline)) +NOINLINE static void handleAddString(VMContext* ctx, RValue a, RValue b, uint8_t resultType) { if (a.type == RVALUE_STRING && b.type == RVALUE_STRING) { // String concatenation @@ -1509,7 +1509,7 @@ static void handleAddString(VMContext* ctx, RValue a, RValue b, uint8_t resultTy } } -__attribute__((noinline)) +NOINLINE static void handleMulString(VMContext* ctx, RValue a, RValue b, uint8_t resultType) { // a.type == RVALUE_STRING; b is the repetition count. int count = RValue_toInt32(b); From c5ea2d3ad166166757cf50bc6dde60ba62f64315 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Tue, 16 Jun 2026 14:55:59 -0400 Subject: [PATCH 03/21] use macro --- src/ps2/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ps2/main.c b/src/ps2/main.c index d6ec8182c..e779821c1 100644 --- a/src/ps2/main.c +++ b/src/ps2/main.c @@ -63,7 +63,7 @@ static int MAX_MEMORY_BYTES = 0; static int heapCeilingBytes = 0; // 256-byte aligned buffers for libpad (one per port) -static char padBuf[2][256] __attribute__((aligned(64))); +static char padBuf[2][256] ALIGN(64); // Controller button to GML key mapping typedef struct { From 002cd4fbbe4050bf96fa8ad958ed3c5a4605a42e Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Tue, 16 Jun 2026 14:56:45 -0400 Subject: [PATCH 04/21] what about now --- src/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.h b/src/utils.h index d61c27434..6e227ab87 100644 --- a/src/utils.h +++ b/src/utils.h @@ -56,7 +56,7 @@ static inline void requireMessageFormatted(const char *file, int line, bool cond } #define requireNotNullMessage(ptr, msg) ({ \ -void *_val = (ptr); \ +const void *_val = (ptr); \ if (_val == NULL) { \ fprintf(stderr, "%s:%d: requireNotNull failed: %s\n", __FILE__, __LINE__, (msg)); \ abort(); \ From 202ca168bcb0dc6f670b7bff378d8d98f6af8ecc Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Tue, 16 Jun 2026 14:58:48 -0400 Subject: [PATCH 05/21] fix --- src/utils.h | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/utils.h b/src/utils.h index 6e227ab87..81fd307da 100644 --- a/src/utils.h +++ b/src/utils.h @@ -55,16 +55,15 @@ static inline void requireMessageFormatted(const char *file, int line, bool cond abort(); } -#define requireNotNullMessage(ptr, msg) ({ \ -const void *_val = (ptr); \ -if (_val == NULL) { \ -fprintf(stderr, "%s:%d: requireNotNull failed: %s\n", __FILE__, __LINE__, (msg)); \ -abort(); \ -} \ -_val; \ -}) - -#define requireNotNull(ptr) requireNotNullMessage(ptr, #ptr) +static inline void* requireNotNullFunction(void* ptr, char* file, int line, char* name) { + if (ptr == nullptr) { + fprintf(stderr, "%s:%d: requireNotNull failed: '%s'\n", file, line, name); + abort(); + } + return ptr; +} +#define requireNotNull(ptr) requireNotNullFunction((void*)ptr, __FILE__, __LINE__, #ptr) +#define requireNotNullMessage(ptr, msg) requireNotNullFunction((void*)ptr, __FILE__, __LINE__, msg) // Safe allocation macros - check for nullptr and abort with file/line info #define safeMalloc(size) ({ \ From 46ec151a0c6b7a2c63a6208739584006967909ea Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Tue, 16 Jun 2026 15:00:57 -0400 Subject: [PATCH 06/21] nit --- src/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.h b/src/utils.h index 81fd307da..d2aa286cf 100644 --- a/src/utils.h +++ b/src/utils.h @@ -56,7 +56,7 @@ static inline void requireMessageFormatted(const char *file, int line, bool cond } static inline void* requireNotNullFunction(void* ptr, char* file, int line, char* name) { - if (ptr == nullptr) { + if (!ptr) { fprintf(stderr, "%s:%d: requireNotNull failed: '%s'\n", file, line, name); abort(); } From 76de23a76712f62750f3291c61dc2aee679f4bfe Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Tue, 16 Jun 2026 15:08:54 -0400 Subject: [PATCH 07/21] fixes --- src/math_compat.h | 4 ++++ src/utils.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/math_compat.h b/src/math_compat.h index 24b9deb38..f2db92807 100644 --- a/src/math_compat.h +++ b/src/math_compat.h @@ -108,3 +108,7 @@ static float roundf(float x) { #ifndef INFINITY #define INFINITY (1.0f / 0.0f) #endif + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif diff --git a/src/utils.h b/src/utils.h index d2aa286cf..8060ebcee 100644 --- a/src/utils.h +++ b/src/utils.h @@ -6,13 +6,14 @@ #include #include #include +#include #include "math_compat.h" #include "real_type.h" #if (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 202311L)) \ || defined(__GNUC__) || defined(__clang__) || defined(__TINYC__) - #define TYPEOF(x) typeof(x) + #define TYPEOF(x) __typeof__(x) #else #define TYPEOF(x) long long #endif From 1d66dab89b49d2bec46a7203e5548660e9ced7d3 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 08:03:39 -0400 Subject: [PATCH 08/21] fix --- src/vm_builtins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm_builtins.c b/src/vm_builtins.c index 723c4f182..8e9ab6299 100644 --- a/src/vm_builtins.c +++ b/src/vm_builtins.c @@ -3960,7 +3960,7 @@ static RValue builtin_method(VMContext* ctx, MAYBE_UNUSED RValue* args, int32_t } if (instanceToBeBound == INSTANCE_SELF) { - instanceToBeBound = requireNotNullMessage(ctx->currentInstance, "Trying to bind method to INSTANCE_SELF while there isn't a instance in the current context!")->instanceId; + instanceToBeBound = ((Instance *)requireNotNullMessage(ctx->currentInstance, "Trying to bind method to INSTANCE_SELF while there isn't a instance in the current context!"))->instanceId; } return RValue_makeMethodFromCodeIndexAndInstanceId(codeIndex, instanceToBeBound); From fe22cd30cd08518fb3c3ee9834d52126ed7f9ecd Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 10:59:51 -0400 Subject: [PATCH 09/21] fix --- src/utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.h b/src/utils.h index 8060ebcee..c91bec695 100644 --- a/src/utils.h +++ b/src/utils.h @@ -56,7 +56,7 @@ static inline void requireMessageFormatted(const char *file, int line, bool cond abort(); } -static inline void* requireNotNullFunction(void* ptr, char* file, int line, char* name) { +static inline void* requireNotNullFunction(void* ptr, const char* file, int line, const char* name) { if (!ptr) { fprintf(stderr, "%s:%d: requireNotNull failed: '%s'\n", file, line, name); abort(); From c7aae13072cd44eef930781f3009ae0d0eafdbfd Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 11:02:48 -0400 Subject: [PATCH 10/21] standard C++ workflow --- .github/workflows/build.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cdfe5d48a..a5215ed3c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -390,7 +390,7 @@ jobs: flags: '-std=gnu99 -w' - name: GCC 2.95 compiler: g++-2.95 - flags: '-fpermissive -w' + flags: '-w' name: Build (${{ matrix.name }}) runs-on: ubuntu-latest steps: @@ -408,3 +408,16 @@ jobs: run: | sudo mv butterscotch ~/woody sudo chroot ~/woody /bin/sh --login -c 'make -C /butterscotch NO_COLOR=1 VERBOSE=1 CC="${{ matrix.compiler }} ${{ matrix.flags }}" DESKTOP_BACKEND=sdl1 AUDIO_BACKEND=none SDL1_LIBS='-lSDL' DISABLE_MMD=1' + + build-cxx: + name: Build as C++ + runs-on: ubuntu-24.04 + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Install dependencies + run: sudo apt-get update && sudo apt-get install -y libglfw3-dev + + - name: Build + run: make CC='g++ -std=gnu++98' NO_COLOR=1 VERBOSE=1 From 25d1d5c212174c552780db0a8ce0e0086bfced14 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 11:45:05 -0400 Subject: [PATCH 11/21] last bits --- src/data_win.c | 2 +- src/desktop/backends/glfw3.c | 2 +- src/vm_builtins.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data_win.c b/src/data_win.c index c172908d6..9b45cd098 100644 --- a/src/data_win.c +++ b/src/data_win.c @@ -890,7 +890,7 @@ static void parseBGND(BinaryReader* reader, DataWin* dw) { bg->gms2ExportedSpriteIndex = BinaryReader_readInt32(reader); bg->gms2FrameLength = BinaryReader_readInt64(reader); int tileIdCount = bg->gms2TileCount * bg->gms2ItemsPerTileCount; - bg->gms2TileIds = malloc(tileIdCount*sizeof(uint32_t)); + bg->gms2TileIds = safeMalloc(tileIdCount*sizeof(uint32_t)); repeat(tileIdCount, j) { bg->gms2TileIds[j] = BinaryReader_readUint32(reader); } diff --git a/src/desktop/backends/glfw3.c b/src/desktop/backends/glfw3.c index a4472f570..fec3113f3 100644 --- a/src/desktop/backends/glfw3.c +++ b/src/desktop/backends/glfw3.c @@ -319,7 +319,7 @@ void platformSwapBuffers(void) { } void *platformGetProcAddress(const char *name) { - return glfwGetProcAddress(name); + return (void *)glfwGetProcAddress(name); } enum { diff --git a/src/vm_builtins.c b/src/vm_builtins.c index 8e9ab6299..945aa3547 100644 --- a/src/vm_builtins.c +++ b/src/vm_builtins.c @@ -2766,7 +2766,7 @@ static bool rvalueIsMatrix(RValue rv) { if (rv.type != RVALUE_ARRAY) return false; if (GMLArray_length1D(rv.array) != 16) return false; repeat (16, i) { - RValueType type = GMLArray_slot(rv.array, i)->type; + RValueType type = (RValueType)(GMLArray_slot(rv.array, i)->type); if (type != RVALUE_REAL && type != RVALUE_INT32 && type != RVALUE_INT64) return false; } From 58236ae9b83d3fe29fa961bc34cfde1cc555c18a Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 12:58:33 -0400 Subject: [PATCH 12/21] Werror --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a5215ed3c..93d096e57 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -420,4 +420,4 @@ jobs: run: sudo apt-get update && sudo apt-get install -y libglfw3-dev - name: Build - run: make CC='g++ -std=gnu++98' NO_COLOR=1 VERBOSE=1 + run: make CC='g++ -std=gnu++98 -Wvla -Werror' NO_COLOR=1 VERBOSE=1 From b32d09d36d13a0668b9b4dad3a05d99956d03ad3 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 13:03:36 -0400 Subject: [PATCH 13/21] remove VLAs --- src/vm.h | 14 +++++++++----- src/vm_builtins.c | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/vm.h b/src/vm.h index 352d86e2e..a180c6072 100644 --- a/src/vm.h +++ b/src/vm.h @@ -368,13 +368,17 @@ static inline bool VM_shouldTraceVariable(StringBooleanEntry* traceMap, const ch // "hp" should trace EVERY "hp" variable read/write to ALL objects if (shgeti(traceMap, varName) != -1) return true; // "obj_mainchara.hp" should trace EVERY variable read/write to the "hp" variable on the "obj_mainchara" object. - char formatted[strlen(scopeName) + 1 + strlen(varName) + 1]; - snprintf(formatted, sizeof(formatted), "%s.%s", scopeName, varName); + size_t formattedSize = strlen(scopeName) + 1 + strlen(varName) + 1; + char *formatted = safeMalloc(formattedSize); + snprintf(formatted, formattedSize, "%s.%s", scopeName, varName); if (shgeti(traceMap, formatted) != -1) return true; + free(formatted); if (altScopeName != nullptr) { - char altFormatted[strlen(altScopeName) + 1 + strlen(varName) + 1]; - snprintf(altFormatted, sizeof(altFormatted), "%s.%s", altScopeName, varName); + size_t altFormattedSize = strlen(altScopeName) + 1 + strlen(varName) + 1; + char *altFormatted = safeMalloc(altFormattedSize); + snprintf(altFormatted, altFormattedSize, "%s.%s", altScopeName, varName); if (shgeti(traceMap, altFormatted) != -1) return true; + free(altFormatted); } return false; } @@ -394,4 +398,4 @@ static inline void VM_checkIfVariableShouldBeTracedAndLog(VMContext* ctx, const fprintf(stderr, "VM: [%s] %s %s.%s%s %s %s%s%s\n", ctx->currentCodeName, verb, scopeName, name, indexBuf, arrow, rvalueAsString, instanceIdBuf, additional); free(rvalueAsString); } -#endif \ No newline at end of file +#endif diff --git a/src/vm_builtins.c b/src/vm_builtins.c index 945aa3547..0ecfb294b 100644 --- a/src/vm_builtins.c +++ b/src/vm_builtins.c @@ -1762,7 +1762,7 @@ static RValue builtin_string_length(MAYBE_UNUSED VMContext* ctx, RValue* args, i // https://docs.vultr.com/clang/examples/remove-all-characters-in-a-string-except-alphabets void filterAlphabets(char *str) { - char result[strlen(str) + 1]; + char *result = safeMalloc(strlen(str) + 1); int j = 0; for (int i = 0; str[i] != '\0'; i++) { if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) { @@ -1771,6 +1771,7 @@ void filterAlphabets(char *str) { } result[j] = '\0'; // Null-terminate the result string strcpy(str, result); // Optionally copy back to original string + free(result); } static RValue builtin_string_letters(MAYBE_UNUSED VMContext* ctx, RValue* args, int32_t argCount) { From fccbab0a6487dbaae12d514b5359f69a10052d12 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 13:11:12 -0400 Subject: [PATCH 14/21] zero structs manually --- src/runner.c | 9 ++++++--- src/utils.h | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/runner.c b/src/runner.c index 450122e2f..50d5aa7a7 100644 --- a/src/runner.c +++ b/src/runner.c @@ -723,7 +723,8 @@ static void rebuildDrawableCacheIfDirty(Runner* runner) { int32_t instanceCount = (int32_t) arrlen(runner->instances); repeat(instanceCount, i) { Instance* inst = runner->instances[i]; - Drawable d = {0}; + Drawable d; + ZERO_STRUCT(d); d.type = DRAWABLE_INSTANCE; d.depth = inst->depth; d.instance = inst; @@ -733,7 +734,8 @@ static void rebuildDrawableCacheIfDirty(Runner* runner) { if (!DataWin_isVersionAtLeast(runner->dataWin, 2, 0, 0, 0)) { repeat(room->tileCount, i) { RoomTile* tile = &room->tiles[i]; - Drawable d = {0}; + Drawable d; + ZERO_STRUCT(d); d.type = DRAWABLE_TILE; d.depth = tile->tileDepth; d.tileIndex = (int32_t) i; @@ -743,7 +745,8 @@ static void rebuildDrawableCacheIfDirty(Runner* runner) { size_t runtimeLayersCount = arrlenu(runner->runtimeLayers); repeat(runtimeLayersCount, i) { RuntimeLayer* runtimeLayer = &runner->runtimeLayers[i]; - Drawable d = {0}; + Drawable d; + ZERO_STRUCT(d); d.type = DRAWABLE_LAYER; d.depth = runtimeLayer->depth; d.runtimeLayerId = (int32_t) runtimeLayer->id; diff --git a/src/utils.h b/src/utils.h index c91bec695..af5fc8ce1 100644 --- a/src/utils.h +++ b/src/utils.h @@ -121,6 +121,8 @@ static inline void* requireNotNullFunction(void* ptr, const char* file, int line _ptr; \ }) +#define ZERO_STRUCT(s) memset(&(s), 0, sizeof(s)) + // Truncates to 6 decimal places, matching the HTML5 runner's ClampFloat static inline GMLReal clampFloat(GMLReal f) { return ((GMLReal) ((int64_t) (f * 1000000.0))) / 1000000.0; From e70cdccaa9ba97167c7790847029a92db9cb44a7 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 13:16:27 -0400 Subject: [PATCH 15/21] explicit casts in bzip2 --- vendor/bzip2/bzlib.c | 28 ++++++++++++++-------------- vendor/bzip2/decompress.c | 6 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/vendor/bzip2/bzlib.c b/vendor/bzip2/bzlib.c index 9e02954f7..484bed0e9 100644 --- a/vendor/bzip2/bzlib.c +++ b/vendor/bzip2/bzlib.c @@ -165,7 +165,7 @@ int BZ_API(BZ2_bzCompressInit) if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; if (strm->bzfree == NULL) strm->bzfree = default_bzfree; - s = BZALLOC( sizeof(EState) ); + s = (EState*)BZALLOC( sizeof(EState) ); if (s == NULL) return BZ_MEM_ERROR; s->strm = strm; @@ -174,9 +174,9 @@ int BZ_API(BZ2_bzCompressInit) s->ftab = NULL; n = 100000 * blockSize100k; - s->arr1 = BZALLOC( n * sizeof(UInt32) ); - s->arr2 = BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) ); - s->ftab = BZALLOC( 65537 * sizeof(UInt32) ); + s->arr1 = (UInt32*)BZALLOC( n * sizeof(UInt32) ); + s->arr2 = (UInt32*)BZALLOC( (n+BZ_N_OVERSHOOT) * sizeof(UInt32) ); + s->ftab = (UInt32*)BZALLOC( 65537 * sizeof(UInt32) ); if (s->arr1 == NULL || s->arr2 == NULL || s->ftab == NULL) { if (s->arr1 != NULL) BZFREE(s->arr1); @@ -362,7 +362,7 @@ Bool handle_compress ( bz_stream* strm ) { Bool progress_in = False; Bool progress_out = False; - EState* s = strm->state; + EState* s = (EState*)strm->state; while (True) { @@ -409,7 +409,7 @@ int BZ_API(BZ2_bzCompress) ( bz_stream *strm, int action ) Bool progress; EState* s; if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; + s = (EState*)strm->state; if (s == NULL) return BZ_PARAM_ERROR; if (s->strm != strm) return BZ_PARAM_ERROR; @@ -469,7 +469,7 @@ int BZ_API(BZ2_bzCompressEnd) ( bz_stream *strm ) { EState* s; if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; + s = (EState*)strm->state; if (s == NULL) return BZ_PARAM_ERROR; if (s->strm != strm) return BZ_PARAM_ERROR; @@ -505,7 +505,7 @@ int BZ_API(BZ2_bzDecompressInit) if (strm->bzalloc == NULL) strm->bzalloc = default_bzalloc; if (strm->bzfree == NULL) strm->bzfree = default_bzfree; - s = BZALLOC( sizeof(DState) ); + s = (DState*)BZALLOC( sizeof(DState) ); if (s == NULL) return BZ_MEM_ERROR; s->strm = strm; strm->state = s; @@ -810,7 +810,7 @@ int BZ_API(BZ2_bzDecompress) ( bz_stream *strm ) Bool corrupt; DState* s; if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; + s = (DState*)strm->state; if (s == NULL) return BZ_PARAM_ERROR; if (s->strm != strm) return BZ_PARAM_ERROR; @@ -863,7 +863,7 @@ int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ) { DState* s; if (strm == NULL) return BZ_PARAM_ERROR; - s = strm->state; + s = (DState*)strm->state; if (s == NULL) return BZ_PARAM_ERROR; if (s->strm != strm) return BZ_PARAM_ERROR; @@ -934,7 +934,7 @@ BZFILE* BZ_API(BZ2_bzWriteOpen) if (ferror(f)) { BZ_SETERR(BZ_IO_ERROR); return NULL; }; - bzf = malloc ( sizeof(bzFile) ); + bzf = (bzFile*)malloc ( sizeof(bzFile) ); if (bzf == NULL) { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; @@ -982,7 +982,7 @@ void BZ_API(BZ2_bzWrite) { BZ_SETERR(BZ_OK); return; }; bzf->strm.avail_in = len; - bzf->strm.next_in = buf; + bzf->strm.next_in = (char*)buf; while (True) { bzf->strm.avail_out = BZ_MAX_UNUSED; @@ -1107,7 +1107,7 @@ BZFILE* BZ_API(BZ2_bzReadOpen) if (ferror(f)) { BZ_SETERR(BZ_IO_ERROR); return NULL; }; - bzf = malloc ( sizeof(bzFile) ); + bzf = (bzFile*)malloc ( sizeof(bzFile) ); if (bzf == NULL) { BZ_SETERR(BZ_MEM_ERROR); return NULL; }; @@ -1179,7 +1179,7 @@ int BZ_API(BZ2_bzRead) { BZ_SETERR(BZ_OK); return 0; }; bzf->strm.avail_out = len; - bzf->strm.next_out = buf; + bzf->strm.next_out = (char*)buf; while (True) { diff --git a/vendor/bzip2/decompress.c b/vendor/bzip2/decompress.c index a1a0bac89..1bea37974 100644 --- a/vendor/bzip2/decompress.c +++ b/vendor/bzip2/decompress.c @@ -209,13 +209,13 @@ Int32 BZ2_decompress ( DState* s ) s->blockSize100k -= BZ_HDR_0; if (s->smallDecompress) { - s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); - s->ll4 = BZALLOC( + s->ll16 = (UInt16*)BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); + s->ll4 = (UChar*)BZALLOC( ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) ); if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); } else { - s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) ); + s->tt = (UInt32*)BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) ); if (s->tt == NULL) RETURN(BZ_MEM_ERROR); } From fe4cdf8af0e470363562c8d763a23def905f9499 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 13:23:07 -0400 Subject: [PATCH 16/21] last -Wall thing --- .github/workflows/build.yml | 2 +- src/spatial_grid.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93d096e57..4fd4cfd6d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -420,4 +420,4 @@ jobs: run: sudo apt-get update && sudo apt-get install -y libglfw3-dev - name: Build - run: make CC='g++ -std=gnu++98 -Wvla -Werror' NO_COLOR=1 VERBOSE=1 + run: make CC='g++ -std=gnu++98 -Wall -Wvla -Werror' NO_COLOR=1 VERBOSE=1 diff --git a/src/spatial_grid.h b/src/spatial_grid.h index b799ca7d5..640275dbe 100644 --- a/src/spatial_grid.h +++ b/src/spatial_grid.h @@ -59,7 +59,7 @@ static inline SpatialGridRange SpatialGrid_computeCellRange(SpatialGrid* grid, G if (minGridY > grid->gridHeight - 1) minGridY = grid->gridHeight - 1; if (maxGridX > grid->gridWidth - 1) maxGridX = grid->gridWidth - 1; if (maxGridY > grid->gridHeight - 1) maxGridY = grid->gridHeight - 1; - return (SpatialGridRange){ minGridX, minGridY, maxGridX, maxGridY }; + return (SpatialGridRange){ (uint16_t)minGridX, (uint16_t)minGridY, (uint16_t)maxGridX, (uint16_t)maxGridY }; } static inline bool SpatialGrid_instanceOverlapsRange(Instance* instance, SpatialGridRange range) { From 241f379c7174b46a23302af4003ebc3521e2e40a Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 13:29:41 -0400 Subject: [PATCH 17/21] fix --- src/common.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/src/common.h b/src/common.h index 9f3c17ae7..c098ce2e8 100644 --- a/src/common.h +++ b/src/common.h @@ -22,18 +22,14 @@ #define IS_BIG_ENDIAN #endif -#if defined(__has_c_attribute) - #if __has_c_attribute(maybe_unused) - #define MAYBE_UNUSED [[maybe_unused]] - #endif -#endif - -#ifndef MAYBE_UNUSED - #if defined(__GNUC__) || defined(__clang__) - #define MAYBE_UNUSED __attribute__((unused)) - #else - #define MAYBE_UNUSED - #endif +#if defined(__cplusplus) && __cplusplus >= 201703L + #define MAYBE_UNUSED [[maybe_unused]] +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L + #define MAYBE_UNUSED [[maybe_unused]] +#elif defined(__GNUC__) || defined(__clang__) + #define MAYBE_UNUSED __attribute__((unused)) +#else + #define MAYBE_UNUSED #endif #if (defined(__GNUC__) && (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))) || defined(__TINYC__) From 9bd231fc4a2e2e590c551ea035ef68e08075840d Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 15:18:03 -0400 Subject: [PATCH 18/21] explicit casts --- src/audio/miniaudio/ma_audio_system.c | 6 +- src/binary_reader.c | 2 +- src/data_win.c | 142 +++++++++++++------------- src/desktop/main.c | 16 +-- src/event_table.c | 16 +-- src/gl/gl_renderer.c | 36 +++---- src/gl_common/gl_common.c | 10 +- src/gl_legacy/gl_legacy_renderer.c | 24 ++--- src/gml_array.c | 8 +- src/gml_method.c | 6 +- src/ini.c | 12 +-- src/input_recording.c | 8 +- src/instance.c | 2 +- src/int_int_hashmap.c | 2 +- src/int_rvalue_hashmap.c | 2 +- src/json_reader.c | 16 +-- src/noop_audio_system.c | 2 +- src/noop_file_system.c | 14 +-- src/overlay_file_system.c | 14 +-- src/profiler.c | 2 +- src/runner.c | 26 ++--- src/runner_gamepad.c | 4 +- src/runner_keyboard.c | 2 +- src/runner_mouse.c | 2 +- src/rvalue.h | 4 +- src/spatial_grid.c | 4 +- src/string_builder.c | 4 +- src/text_utils.h | 4 +- src/vm.c | 36 +++---- src/vm.h | 6 +- src/vm_builtins.c | 112 ++++++++++---------- 31 files changed, 272 insertions(+), 272 deletions(-) diff --git a/src/audio/miniaudio/ma_audio_system.c b/src/audio/miniaudio/ma_audio_system.c index 93806e239..27ac30408 100644 --- a/src/audio/miniaudio/ma_audio_system.c +++ b/src/audio/miniaudio/ma_audio_system.c @@ -693,11 +693,11 @@ static void maGroupLoad(AudioSystem* audio, int32_t groupIndex) { char* buf; if (audioGroupEntry->path == nullptr) { int sz = snprintf(nullptr, 0, "audiogroup%d.dat", groupIndex); - buf = safeMalloc(sz + 1); + buf = (char *)safeMalloc(sz + 1); snprintf(buf, sz + 1, "audiogroup%d.dat", groupIndex); } else { size_t length = strlen(audioGroupEntry->path); - buf = safeMalloc(length + 1); + buf = (char *)safeMalloc(length + 1); memcpy(buf, audioGroupEntry->path, length); buf[length] = '\0'; } @@ -798,7 +798,7 @@ static AudioSystemVtable maAudioSystemVtable; // ===[ Lifecycle ]=== MaAudioSystem* MaAudioSystem_create(DataWin* dataWin) { - MaAudioSystem* ma = safeCalloc(1, sizeof(MaAudioSystem)); + MaAudioSystem* ma = (MaAudioSystem *)safeCalloc(1, sizeof(MaAudioSystem)); ma->base.dw = dataWin; maAudioSystemVtable.init = maInit; maAudioSystemVtable.destroy = maDestroy; diff --git a/src/binary_reader.c b/src/binary_reader.c index de6a739b6..6490c0884 100644 --- a/src/binary_reader.c +++ b/src/binary_reader.c @@ -106,7 +106,7 @@ void BinaryReader_readBytes(BinaryReader* reader, void* dest, size_t count) { } uint8_t* BinaryReader_readBytesAt(BinaryReader* reader, size_t offset, size_t count) { - uint8_t* buf = safeMalloc(count); + uint8_t* buf = (uint8_t *)safeMalloc(count); if (reader->buffer != nullptr) { if (offset < reader->bufferBase || offset + count > reader->bufferBase + reader->bufferSize) { diff --git a/src/data_win.c b/src/data_win.c index 9b45cd098..8debed9a5 100644 --- a/src/data_win.c +++ b/src/data_win.c @@ -25,7 +25,7 @@ static const char* readStringPtr(BinaryReader* reader, DataWin* dw) { static uint32_t* readPointerTable(BinaryReader* reader, uint32_t* outCount) { *outCount = BinaryReader_readUint32(reader); if (*outCount == 0) return nullptr; - uint32_t* ptrs = safeMalloc(*outCount * sizeof(uint32_t)); + uint32_t* ptrs = (uint32_t *)safeMalloc(*outCount * sizeof(uint32_t)); repeat(*outCount, i) { ptrs[i] = BinaryReader_readUint32(reader); } @@ -39,7 +39,7 @@ static EventAction* readEventActions(BinaryReader* reader, DataWin* dw, uint32_t *outCount = count; if (count == 0) { free(ptrs); return nullptr; } - EventAction* actions = safeMalloc(count * sizeof(EventAction)); + EventAction* actions = (EventAction *)safeMalloc(count * sizeof(EventAction)); repeat(count, i) { BinaryReader_seek(reader, ptrs[i]); actions[i].libID = BinaryReader_readUint32(reader); @@ -152,7 +152,7 @@ void GamePath_computeInternal(GamePath* path) { // ComputeLength (yyPath.js:150-160) path->internalPointCount = tempIntPointCount; - path->internalPoints = safeMalloc(tempIntPointCount * sizeof(InternalPathPoint)); + path->internalPoints = (InternalPathPoint *)safeMalloc(tempIntPointCount * sizeof(InternalPathPoint)); memcpy(path->internalPoints, tempIntPoints, tempIntPointCount * sizeof(InternalPathPoint)); arrfree(tempIntPoints); tempIntPoints = nullptr; @@ -255,7 +255,7 @@ static void parseGEN8(BinaryReader* reader, DataWin* dw) { g->debuggerPort = 0; g->roomOrderCount = BinaryReader_readUint32(reader); if (g->roomOrderCount > 0) { - g->roomOrder = safeMalloc(g->roomOrderCount * sizeof(int32_t)); + g->roomOrder = (int32_t *)safeMalloc(g->roomOrderCount * sizeof(int32_t)); repeat(g->roomOrderCount, i) { g->roomOrder[i] = BinaryReader_readInt32(reader); } @@ -296,7 +296,7 @@ static void parseGEN8(BinaryReader* reader, DataWin* dw) { g->functionClassifications = (g->wadVersion >= 12) ? BinaryReader_readUint64(reader) : 0; g->roomOrderCount = BinaryReader_readUint32(reader); if (g->roomOrderCount > 0) { - g->roomOrder = safeMalloc(g->roomOrderCount * sizeof(int32_t)); + g->roomOrder = (int32_t *)safeMalloc(g->roomOrderCount * sizeof(int32_t)); repeat(g->roomOrderCount, i) { g->roomOrder[i] = BinaryReader_readInt32(reader); } @@ -321,7 +321,7 @@ static void parseGEN8(BinaryReader* reader, DataWin* dw) { // Room order SimpleList g->roomOrderCount = BinaryReader_readUint32(reader); if (g->roomOrderCount > 0) { - g->roomOrder = safeMalloc(g->roomOrderCount * sizeof(int32_t)); + g->roomOrder = (int32_t *)safeMalloc(g->roomOrderCount * sizeof(int32_t)); repeat(g->roomOrderCount, i) { g->roomOrder[i] = BinaryReader_readInt32(reader); } @@ -413,7 +413,7 @@ static void parseOPTN(BinaryReader* reader, DataWin* dw) { } o->constantCount = BinaryReader_readUint32(reader); if (o->constantCount > 0) { - o->constants = safeMalloc(o->constantCount * sizeof(OptnConstant)); + o->constants = (OptnConstant *)safeMalloc(o->constantCount * sizeof(OptnConstant)); repeat(o->constantCount, i) { o->constants[i].name = readStringPtr(reader, dw); o->constants[i].value = readStringPtr(reader, dw); @@ -431,7 +431,7 @@ static void parseLANG(BinaryReader* reader, DataWin* dw) { // Entry IDs if (l->entryCount > 0) { - l->entryIds = safeMalloc(l->entryCount * sizeof(const char*)); + l->entryIds = (const char **)safeMalloc(l->entryCount * sizeof(const char*)); repeat(l->entryCount, i) { l->entryIds[i] = readStringPtr(reader, dw); } @@ -441,13 +441,13 @@ static void parseLANG(BinaryReader* reader, DataWin* dw) { // Languages if (l->languageCount > 0) { - l->languages = safeMalloc(l->languageCount * sizeof(Language)); + l->languages = (Language *)safeMalloc(l->languageCount * sizeof(Language)); repeat(l->languageCount, i) { l->languages[i].name = readStringPtr(reader, dw); l->languages[i].region = readStringPtr(reader, dw); l->languages[i].entryCount = l->entryCount; if (l->entryCount > 0) { - l->languages[i].entries = safeMalloc(l->entryCount * sizeof(const char*)); + l->languages[i].entries = (const char **)safeMalloc(l->entryCount * sizeof(const char*)); repeat(l->entryCount, j) { l->languages[i].entries[j] = readStringPtr(reader, dw); } @@ -494,7 +494,7 @@ static void parseEXTN(BinaryReader* reader, DataWin* dw) { } } - e->extensions = safeMalloc(extCount * sizeof(Extension)); + e->extensions = (Extension *)safeMalloc(extCount * sizeof(Extension)); repeat(extCount, i) { BinaryReader_seek(reader, extPtrs[i]); Extension* ext = &e->extensions[i]; @@ -519,7 +519,7 @@ static void parseEXTN(BinaryReader* reader, DataWin* dw) { ext->fileCount = fileCount; if (fileCount > 0) { - ext->files = safeMalloc(fileCount * sizeof(ExtensionFile)); + ext->files = (ExtensionFile *)safeMalloc(fileCount * sizeof(ExtensionFile)); repeat(fileCount, j) { BinaryReader_seek(reader, filePtrs[j]); ExtensionFile* file = &ext->files[j]; @@ -534,7 +534,7 @@ static void parseEXTN(BinaryReader* reader, DataWin* dw) { file->functionCount = funcCount; if (funcCount > 0) { - file->functions = safeMalloc(funcCount * sizeof(ExtensionFunction)); + file->functions = (ExtensionFunction *)safeMalloc(funcCount * sizeof(ExtensionFunction)); repeat(funcCount, k) { BinaryReader_seek(reader, funcPtrs[k]); ExtensionFunction* func = &file->functions[k]; @@ -547,7 +547,7 @@ static void parseEXTN(BinaryReader* reader, DataWin* dw) { // Arguments SimpleList func->argumentCount = BinaryReader_readUint32(reader); if (func->argumentCount > 0) { - func->arguments = safeMalloc(func->argumentCount * sizeof(uint32_t)); + func->arguments = (uint32_t *)safeMalloc(func->argumentCount * sizeof(uint32_t)); repeat(func->argumentCount, a) { func->arguments[a] = BinaryReader_readUint32(reader); } @@ -606,7 +606,7 @@ static void parseSOND(BinaryReader* reader, DataWin* dw) { } } - s->sounds = safeCalloc(count, sizeof(Sound)); + s->sounds = (Sound *)safeCalloc(count, sizeof(Sound)); repeat(count, i) { if (ptrs[i] == 0) continue; BinaryReader_seek(reader, ptrs[i]); @@ -691,7 +691,7 @@ static void parseAGRP(BinaryReader* reader, DataWin* dw) { } } - a->audioGroups = safeCalloc(count, sizeof(AudioGroup)); + a->audioGroups = (AudioGroup *)safeCalloc(count, sizeof(AudioGroup)); repeat(count, i) { if (ptrs[i] == 0) continue; @@ -714,7 +714,7 @@ static void parseSPRT(BinaryReader* reader, DataWin* dw, bool skipLoadingPrecise if (count == 0) { free(ptrs); s->sprites = nullptr; return; } - s->sprites = safeCalloc(count, sizeof(Sprite)); + s->sprites = (Sprite *)safeCalloc(count, sizeof(Sprite)); repeat(count, i) { if (ptrs[i] == 0) continue; BinaryReader_seek(reader, ptrs[i]); @@ -772,7 +772,7 @@ static void parseSPRT(BinaryReader* reader, DataWin* dw, bool skipLoadingPrecise spr->textureCount = (uint32_t)check; if (spr->textureCount > 0) { // Temporarily store the absolute file offsets here; parseTPAG resolves them in-place to TPAG indices once the TPAG table is known. - spr->tpagIndices = safeMalloc(spr->textureCount * sizeof(int32_t)); + spr->tpagIndices = (int32_t *)safeMalloc(spr->textureCount * sizeof(int32_t)); repeat(spr->textureCount, j) { spr->tpagIndices[j] = (int32_t) BinaryReader_readUint32(reader); } @@ -814,9 +814,9 @@ static void parseSPRT(BinaryReader* reader, DataWin* dw, bool skipLoadingPrecise uint32_t bytesPerMask = bytesPerRow * spr->maskHeight; if (spr->sepMasks == 1 || !skipLoadingPreciseMasksForNonPreciseSprites) { - spr->masks = safeMalloc(maskDataCount * sizeof(uint8_t*)); + spr->masks = (uint8_t **)safeMalloc(maskDataCount * sizeof(uint8_t*)); repeat(maskDataCount, j) { - spr->masks[j] = safeMalloc(bytesPerMask); + spr->masks[j] = (uint8_t *)safeMalloc(bytesPerMask); BinaryReader_readBytes(reader, spr->masks[j], bytesPerMask); } } else { @@ -862,7 +862,7 @@ static void parseBGND(BinaryReader* reader, DataWin* dw) { if (count == 0) { free(ptrs); b->backgrounds = nullptr; return; } - b->backgrounds = safeCalloc(count, sizeof(Background)); + b->backgrounds = (Background *)safeCalloc(count, sizeof(Background)); repeat(count, i) { if (ptrs[i] == 0) continue; BinaryReader_seek(reader, ptrs[i]); @@ -890,7 +890,7 @@ static void parseBGND(BinaryReader* reader, DataWin* dw) { bg->gms2ExportedSpriteIndex = BinaryReader_readInt32(reader); bg->gms2FrameLength = BinaryReader_readInt64(reader); int tileIdCount = bg->gms2TileCount * bg->gms2ItemsPerTileCount; - bg->gms2TileIds = safeMalloc(tileIdCount*sizeof(uint32_t)); + bg->gms2TileIds = (uint32_t *)safeMalloc(tileIdCount*sizeof(uint32_t)); repeat(tileIdCount, j) { bg->gms2TileIds[j] = BinaryReader_readUint32(reader); } @@ -908,7 +908,7 @@ static void parsePATH(BinaryReader* reader, DataWin* dw) { if (count == 0) { free(ptrs); p->paths = nullptr; return; } - p->paths = safeCalloc(count, sizeof(GamePath)); + p->paths = (GamePath *)safeCalloc(count, sizeof(GamePath)); repeat(count, i) { if (ptrs[i] == 0) continue; BinaryReader_seek(reader, ptrs[i]); @@ -925,7 +925,7 @@ static void parsePATH(BinaryReader* reader, DataWin* dw) { // Points SimpleList path->pointCount = BinaryReader_readUint32(reader); if (path->pointCount > 0) { - path->points = safeMalloc(path->pointCount * sizeof(PathPoint)); + path->points = (PathPoint *)safeMalloc(path->pointCount * sizeof(PathPoint)); repeat(path->pointCount, j) { path->points[j].x = BinaryReader_readFloat32(reader); path->points[j].y = BinaryReader_readFloat32(reader); @@ -950,7 +950,7 @@ static void parseSCPT(BinaryReader* reader, DataWin* dw) { if (count == 0) { free(ptrs); s->scripts = nullptr; return; } - s->scripts = safeCalloc(count, sizeof(Script)); + s->scripts = (Script *)safeCalloc(count, sizeof(Script)); repeat(count, i) { if (ptrs[i] == 0) { s->scripts[i].codeId = -1; continue; } BinaryReader_seek(reader, ptrs[i]); @@ -1003,7 +1003,7 @@ static void parseACRV(BinaryReader* reader, DataWin* dw) { // Whether the per-point format includes the 4 trailing float bezier handles (24 bytes) instead of the 2.3.0 layout (12 bytes, just X/Value + 4 pad). bool isV231Plus = DataWin_isVersionAtLeast(dw, 2, 3, 1, 0); - a->curves = safeCalloc(count, sizeof(AnimCurve)); + a->curves = (AnimCurve *)safeCalloc(count, sizeof(AnimCurve)); uint32_t globalChannelCount = 0; repeat(count, i) { @@ -1014,14 +1014,14 @@ static void parseACRV(BinaryReader* reader, DataWin* dw) { cur->name = readStringPtr(reader, dw); cur->graphType = BinaryReader_readUint32(reader); cur->channelCount = BinaryReader_readUint32(reader); - cur->channels = (cur->channelCount > 0) ? safeCalloc(cur->channelCount, sizeof(AnimCurveChannel)) : nullptr; + cur->channels = (cur->channelCount > 0) ? (AnimCurveChannel *)safeCalloc(cur->channelCount, sizeof(AnimCurveChannel)) : nullptr; repeat(cur->channelCount, c) { AnimCurveChannel* ch = &cur->channels[c]; ch->name = readStringPtr(reader, dw); ch->curveType = (AnimCurveType) BinaryReader_readUint32(reader); ch->iterations = BinaryReader_readUint32(reader); ch->pointCount = BinaryReader_readUint32(reader); - ch->points = (ch->pointCount > 0) ? safeMalloc(ch->pointCount * sizeof(AnimCurvePoint)) : nullptr; + ch->points = (ch->pointCount > 0) ? (AnimCurvePoint *)safeMalloc(ch->pointCount * sizeof(AnimCurvePoint)) : nullptr; repeat(ch->pointCount, p) { AnimCurvePoint* pt = &ch->points[p]; pt->x = BinaryReader_readFloat32(reader); @@ -1045,7 +1045,7 @@ static void parseACRV(BinaryReader* reader, DataWin* dw) { // Build the flat global channel table for handle resolution a->allChannelsCount = globalChannelCount; if (globalChannelCount > 0) { - a->allChannels = safeMalloc(globalChannelCount * sizeof(AnimCurveChannel*)); + a->allChannels = (AnimCurveChannel **)safeMalloc(globalChannelCount * sizeof(AnimCurveChannel*)); uint32_t idx = 0; repeat(count, i) { AnimCurve* cur = &a->curves[i]; @@ -1064,7 +1064,7 @@ static void parseGLOB(BinaryReader* reader, DataWin* dw) { g->count = BinaryReader_readUint32(reader); if (g->count > 0) { - g->codeIds = safeMalloc(g->count * sizeof(int32_t)); + g->codeIds = (int32_t *)safeMalloc(g->count * sizeof(int32_t)); repeat(g->count, i) { g->codeIds[i] = BinaryReader_readInt32(reader); } @@ -1077,7 +1077,7 @@ static void parseSHDR(BinaryReader* reader, DataWin* dw) { Shdr* s = &dw->shdr; uint32_t* ptrs = readPointerTable(reader, &s->count); - s->shaders = safeMalloc(s->count * sizeof(Shader)); + s->shaders = (Shader *)safeMalloc(s->count * sizeof(Shader)); repeat(s->count, i) { // Some GameMaker games have a nullptr for the shader, so we'll just mark them as not-present... @@ -1104,7 +1104,7 @@ static void parseSHDR(BinaryReader* reader, DataWin* dw) { // Vertex attributes SimpleList sh->vertexAttributeCount = BinaryReader_readUint32(reader); if (sh->vertexAttributeCount > 0) { - sh->vertexAttributes = safeMalloc(sh->vertexAttributeCount * sizeof(const char*)); + sh->vertexAttributes = (const char **)safeMalloc(sh->vertexAttributeCount * sizeof(const char*)); repeat(sh->vertexAttributeCount, j) { sh->vertexAttributes[j] = readStringPtr(reader, dw); } @@ -1184,7 +1184,7 @@ static void parseFONT(BinaryReader* reader, DataWin* dw) { } } - f->fonts = safeCalloc(count, sizeof(Font)); + f->fonts = (Font *)safeCalloc(count, sizeof(Font)); repeat(count, i) { if (ptrs[i] == 0) continue; BinaryReader_seek(reader, ptrs[i]); @@ -1243,7 +1243,7 @@ static void parseFONT(BinaryReader* reader, DataWin* dw) { uint32_t maxGlyphHeight = 0; if (glyphCount > 0) { - font->glyphs = safeMalloc(glyphCount * sizeof(FontGlyph)); + font->glyphs = (FontGlyph *)safeMalloc(glyphCount * sizeof(FontGlyph)); repeat(glyphCount, j) { BinaryReader_seek(reader, glyphPtrs[j]); FontGlyph* glyph = &font->glyphs[j]; @@ -1260,7 +1260,7 @@ static void parseFONT(BinaryReader* reader, DataWin* dw) { // Kerning SimpleListShort (uint16 count) glyph->kerningCount = BinaryReader_readUint16(reader); if (glyph->kerningCount > 0) { - glyph->kerning = safeMalloc(glyph->kerningCount * sizeof(KerningPair)); + glyph->kerning = (KerningPair *)safeMalloc(glyph->kerningCount * sizeof(KerningPair)); for (uint16_t k = 0; glyph->kerningCount > k; k++) { glyph->kerning[k].character = BinaryReader_readInt16(reader); glyph->kerning[k].shiftModifier = BinaryReader_readInt16(reader); @@ -1290,7 +1290,7 @@ static void parseTMLN(BinaryReader* reader, DataWin* dw) { if (count == 0) { free(ptrs); t->timelines = nullptr; return; } - t->timelines = safeCalloc(count, sizeof(Timeline)); + t->timelines = (Timeline *)safeCalloc(count, sizeof(Timeline)); repeat(count, i) { if (ptrs[i] == 0) continue; BinaryReader_seek(reader, ptrs[i]); @@ -1300,10 +1300,10 @@ static void parseTMLN(BinaryReader* reader, DataWin* dw) { tl->momentCount = BinaryReader_readUint32(reader); if (tl->momentCount > 0) { - tl->moments = safeMalloc(tl->momentCount * sizeof(TimelineMoment)); + tl->moments = (TimelineMoment *)safeMalloc(tl->momentCount * sizeof(TimelineMoment)); // Pass 1: Read step + event pointer pairs - uint32_t* eventPtrs = safeMalloc(tl->momentCount * sizeof(uint32_t)); + uint32_t* eventPtrs = (uint32_t *)safeMalloc(tl->momentCount * sizeof(uint32_t)); repeat(tl->momentCount, j) { tl->moments[j].step = BinaryReader_readUint32(reader); eventPtrs[j] = BinaryReader_readUint32(reader); @@ -1363,7 +1363,7 @@ static void parseOBJT(BinaryReader* reader, DataWin* dw) { } } - o->objects = safeCalloc(count, sizeof(GameObject)); + o->objects = (GameObject *)safeCalloc(count, sizeof(GameObject)); repeat(count, i) { if (ptrs[i] == 0) { o->objects[i].parentId = -1; o->objects[i].spriteId = -1; o->objects[i].textureMaskId = -1; continue; } BinaryReader_seek(reader, ptrs[i]); @@ -1404,7 +1404,7 @@ static void parseOBJT(BinaryReader* reader, DataWin* dw) { // Physics vertices if (obj->physicsVertexCount > 0) { - obj->physicsVertices = safeMalloc(obj->physicsVertexCount * sizeof(PhysicsVertex)); + obj->physicsVertices = (PhysicsVertex *)safeMalloc(obj->physicsVertexCount * sizeof(PhysicsVertex)); for (int32_t j = 0; obj->physicsVertexCount > j; j++) { obj->physicsVertices[j].x = BinaryReader_readFloat32(reader); obj->physicsVertices[j].y = BinaryReader_readFloat32(reader); @@ -1429,7 +1429,7 @@ static void parseOBJT(BinaryReader* reader, DataWin* dw) { obj->eventLists[eventType].eventCount = eventCount; if (eventCount > 0) { - obj->eventLists[eventType].events = safeMalloc(eventCount * sizeof(ObjectEvent)); + obj->eventLists[eventType].events = (ObjectEvent *)safeMalloc(eventCount * sizeof(ObjectEvent)); repeat(eventCount, j) { BinaryReader_seek(reader, eventPtrs[j]); obj->eventLists[eventType].events[j].eventSubtype = BinaryReader_readUint32(reader); @@ -1461,7 +1461,7 @@ static void parseOBJT(BinaryReader* reader, DataWin* dw) { static void readRoomBackgrounds(BinaryReader* reader, Room* room) { uint32_t bgCount; uint32_t* bgPtrs = readPointerTable(reader, &bgCount); - room->backgrounds = safeMalloc(8 * sizeof(RoomBackground)); + room->backgrounds = (RoomBackground *)safeMalloc(8 * sizeof(RoomBackground)); uint32_t fillEnd = bgCount < 8 ? bgCount : 8; for (uint32_t j = 0; fillEnd > j; j++) { BinaryReader_seek(reader, bgPtrs[j]); @@ -1486,7 +1486,7 @@ static void readRoomBackgrounds(BinaryReader* reader, Room* room) { static void readRoomViews(BinaryReader* reader, Room* room) { uint32_t viewCount; uint32_t* viewPtrsArr = readPointerTable(reader, &viewCount); - room->views = safeMalloc(8 * sizeof(RoomView)); + room->views = (RoomView *)safeMalloc(8 * sizeof(RoomView)); for (uint32_t j = 0; viewCount > j && 8 > j; j++) { BinaryReader_seek(reader, viewPtrsArr[j]); RoomView* view = &room->views[j]; @@ -1516,7 +1516,7 @@ static void readRoomGameObjects(BinaryReader* reader, DataWin* dw, Room* room) { uint32_t* objPtrs = readPointerTable(reader, &objCount); room->gameObjectCount = objCount; if (objCount > 0) { - room->gameObjects = safeMalloc(objCount * sizeof(RoomGameObject)); + room->gameObjects = (RoomGameObject *)safeMalloc(objCount * sizeof(RoomGameObject)); repeat(objCount, j) { BinaryReader_seek(reader, objPtrs[j]); RoomGameObject* go = &room->gameObjects[j]; @@ -1559,7 +1559,7 @@ static void readRoomTiles(BinaryReader* reader, DataWin* dw, Room* room) { uint32_t* tilePtrs = readPointerTable(reader, &tileCount); room->tileCount = tileCount; if (tileCount > 0) { - room->tiles = safeMalloc(tileCount * sizeof(RoomTile)); + room->tiles = (RoomTile *)safeMalloc(tileCount * sizeof(RoomTile)); repeat(tileCount, j) { BinaryReader_seek(reader, tilePtrs[j]); RoomTile* tile = &room->tiles[j]; @@ -1595,7 +1595,7 @@ static void readRoomLayers(BinaryReader* reader, DataWin* dw, Room* room) { return; } - room->layers = safeMalloc(layerCount * sizeof(RoomLayer)); + room->layers = (RoomLayer *)safeMalloc(layerCount * sizeof(RoomLayer)); repeat(layerCount, j) { BinaryReader_seek(reader, layerPtrs[j]); RoomLayer* layer = &room->layers[j]; @@ -1634,14 +1634,14 @@ static void readRoomLayers(BinaryReader* reader, DataWin* dw, Room* room) { break; case RoomLayerType_Assets: { - RoomLayerAssetsData* assets = safeMalloc(sizeof(RoomLayerAssetsData)); + RoomLayerAssetsData* assets = (RoomLayerAssetsData *)safeMalloc(sizeof(RoomLayerAssetsData)); uint32_t legacyTilesPtr = BinaryReader_readUint32(reader); uint32_t spritesPtr = BinaryReader_readUint32(reader); BinaryReader_seek(reader, legacyTilesPtr); uint32_t *innerTilePtrs = readPointerTable(reader, &assets->legacyTileCount); if (assets->legacyTileCount > 0) { - assets->legacyTiles = safeMalloc(assets->legacyTileCount * sizeof(RoomTile)); + assets->legacyTiles = (RoomTile *)safeMalloc(assets->legacyTileCount * sizeof(RoomTile)); repeat(assets->legacyTileCount, k) { BinaryReader_seek(reader, innerTilePtrs[k]); RoomTile* tile = &assets->legacyTiles[k]; @@ -1668,7 +1668,7 @@ static void readRoomLayers(BinaryReader* reader, DataWin* dw, Room* room) { BinaryReader_seek(reader, spritesPtr); uint32_t *spritePtrs = readPointerTable(reader, &assets->spriteCount); if (assets->spriteCount > 0) { - assets->sprites = safeMalloc(assets->spriteCount * sizeof(SpriteInstance)); + assets->sprites = (SpriteInstance *)safeMalloc(assets->spriteCount * sizeof(SpriteInstance)); repeat(assets->spriteCount, k) { BinaryReader_seek(reader, spritePtrs[k]); SpriteInstance* sprite = &assets->sprites[k]; @@ -1694,7 +1694,7 @@ static void readRoomLayers(BinaryReader* reader, DataWin* dw, Room* room) { } case RoomLayerType_Background: { - RoomLayerBackgroundData* bg = safeMalloc(sizeof(RoomLayerBackgroundData)); + RoomLayerBackgroundData* bg = (RoomLayerBackgroundData *)safeMalloc(sizeof(RoomLayerBackgroundData)); bg->visible = BinaryReader_readBool32(reader); bg->foreground = BinaryReader_readBool32(reader); bg->spriteIndex = BinaryReader_readInt32(reader); @@ -1709,10 +1709,10 @@ static void readRoomLayers(BinaryReader* reader, DataWin* dw, Room* room) { break; } case RoomLayerType_Instances: { - RoomLayerInstancesData* inst = safeMalloc(sizeof(RoomLayerInstancesData)); + RoomLayerInstancesData* inst = (RoomLayerInstancesData *)safeMalloc(sizeof(RoomLayerInstancesData)); inst->instanceCount = BinaryReader_readUint32(reader); if (inst->instanceCount > 0) { - inst->instanceIds = safeMalloc(inst->instanceCount * sizeof(uint32_t)); + inst->instanceIds = (uint32_t *)safeMalloc(inst->instanceCount * sizeof(uint32_t)); repeat(inst->instanceCount, k) { inst->instanceIds[k] = BinaryReader_readUint32(reader); } @@ -1723,13 +1723,13 @@ static void readRoomLayers(BinaryReader* reader, DataWin* dw, Room* room) { break; } case RoomLayerType_Tiles: { - RoomLayerTilesData* tiles = safeMalloc(sizeof(RoomLayerTilesData)); + RoomLayerTilesData* tiles = (RoomLayerTilesData *)safeMalloc(sizeof(RoomLayerTilesData)); tiles->backgroundIndex = BinaryReader_readInt32(reader); tiles->tilesX = BinaryReader_readUint32(reader); tiles->tilesY = BinaryReader_readUint32(reader); uint32_t totalTiles = tiles->tilesX * tiles->tilesY; if (totalTiles > 0) { - tiles->tileData = safeMalloc(totalTiles * sizeof(uint32_t)); + tiles->tileData = (uint32_t *)safeMalloc(totalTiles * sizeof(uint32_t)); if (DataWin_isVersionAtLeast(dw, 2024, 2, 0, 0)) { // GM 2024.2+ games have RLE-compressed tile data // GM 2024.4+ aligns to 4 bytes after the stream @@ -1915,7 +1915,7 @@ static void parseROOM(BinaryReader* reader, DataWin* dw, bool lazyLoadRooms, Str } } - rc->rooms = safeCalloc(count, sizeof(Room)); + rc->rooms = (Room *)safeCalloc(count, sizeof(Room)); repeat(count, i) { if (ptrs[i] == 0) { rc->rooms[i].creationCodeId = -1; continue; } BinaryReader_seek(reader, ptrs[i]); @@ -1988,7 +1988,7 @@ static int32_t parseTexturePageItem(BinaryReader* reader, DataWin* dw, int32_t i if (i == -1) { fprintf(stderr, "DataWin: Allocated new TPAG! Was the WAD built with WinPack? (TranslaTale)\n"); uint32_t newCount = dw->tpag.count + 1; - TexturePageItem* newItems = safeCalloc(newCount, sizeof(TexturePageItem)); + TexturePageItem* newItems = (TexturePageItem *)safeCalloc(newCount, sizeof(TexturePageItem)); memcpy(newItems, dw->tpag.items, dw->tpag.count * sizeof(TexturePageItem)); free(dw->tpag.items); @@ -2080,7 +2080,7 @@ static void parseTPAG(BinaryReader* reader, DataWin* dw) { if (count == 0) { free(ptrs); t->items = nullptr; return; } - t->items = safeCalloc(count, sizeof(TexturePageItem)); + t->items = (TexturePageItem *)safeCalloc(count, sizeof(TexturePageItem)); repeat(count, i) { if (ptrs[i] == 0) { t->items[i].texturePageId = -1; continue; } BinaryReader_seek(reader, ptrs[i]); @@ -2113,7 +2113,7 @@ static void parseCODE(BinaryReader* reader, DataWin* dw, uint32_t chunkLength, s bool oldFormat = 14 >= dw->gen8.wadVersion; - c->entries = safeCalloc(codeCount, sizeof(CodeEntry)); + c->entries = (CodeEntry *)safeCalloc(codeCount, sizeof(CodeEntry)); repeat(codeCount, i) { if (codePtrs[i] == 0) continue; BinaryReader_seek(reader, codePtrs[i]); @@ -2190,7 +2190,7 @@ static void parseVARI(BinaryReader* reader, DataWin* dw, uint32_t chunkLength) { } if (v->variableCount > 0) { - v->variables = safeMalloc(v->variableCount * sizeof(Variable)); + v->variables = (Variable *)safeMalloc(v->variableCount * sizeof(Variable)); repeat(v->variableCount, i) { Variable* var = &v->variables[i]; var->name = readStringPtr(reader, dw); @@ -2216,7 +2216,7 @@ static void parseFUNC(BinaryReader* reader, DataWin* dw, uint32_t chunkLength) { if (dw->gen8.wadVersion <= 14) { f->functionCount = chunkLength / 12; if (f->functionCount > 0) { - f->functions = safeMalloc(f->functionCount * sizeof(Function)); + f->functions = (Function *)safeMalloc(f->functionCount * sizeof(Function)); repeat(f->functionCount, i) { f->functions[i].name = readStringPtr(reader, dw); f->functions[i].occurrences = BinaryReader_readUint32(reader); @@ -2265,7 +2265,7 @@ static void parseFUNC(BinaryReader* reader, DataWin* dw, uint32_t chunkLength) { // Part 1: Functions SimpleList f->functionCount = BinaryReader_readUint32(reader); if (f->functionCount > 0) { - f->functions = safeMalloc(f->functionCount * sizeof(Function)); + f->functions = (Function *)safeMalloc(f->functionCount * sizeof(Function)); repeat(f->functionCount, i) { f->functions[i].name = readStringPtr(reader, dw); f->functions[i].occurrences = BinaryReader_readUint32(reader); @@ -2288,14 +2288,14 @@ static void parseFUNC(BinaryReader* reader, DataWin* dw, uint32_t chunkLength) { } f->codeLocalsCount = BinaryReader_readUint32(reader); if (f->codeLocalsCount > 0) { - f->codeLocals = safeMalloc(f->codeLocalsCount * sizeof(CodeLocals)); + f->codeLocals = (CodeLocals *)safeMalloc(f->codeLocalsCount * sizeof(CodeLocals)); repeat(f->codeLocalsCount, i) { CodeLocals* cl = &f->codeLocals[i]; cl->localVarCount = BinaryReader_readUint32(reader); cl->name = readStringPtr(reader, dw); if (cl->localVarCount > 0) { - cl->locals = safeMalloc(cl->localVarCount * sizeof(LocalVar)); + cl->locals = (LocalVar *)safeMalloc(cl->localVarCount * sizeof(LocalVar)); repeat(cl->localVarCount, j) { cl->locals[j].varID = BinaryReader_readUint32(reader); cl->locals[j].name = readStringPtr(reader, dw); @@ -2318,7 +2318,7 @@ static void parseSTRG(BinaryReader* reader, DataWin* dw) { if (count == 0) { free(ptrs); s->strings = nullptr; return; } - s->strings = safeCalloc(count, sizeof(const char*)); + s->strings = (const char **)safeCalloc(count, sizeof(const char*)); repeat(count, i) { if (ptrs[i] == 0) continue; // Pointer table points to the string's length prefix. @@ -2360,7 +2360,7 @@ static void parseTXTR(BinaryReader* reader, DataWin* dw, size_t chunkEnd) { } } - t->textures = safeCalloc(count, sizeof(Texture)); + t->textures = (Texture *)safeCalloc(count, sizeof(Texture)); repeat(count, i) { if (ptrs[i] == 0) { t->textures[i].blobOffset = 0; t->textures[i].blobData = nullptr; continue; } BinaryReader_seek(reader, ptrs[i]); @@ -2419,7 +2419,7 @@ static void parseAUDO(BinaryReader* reader, DataWin* dw) { if (count == 0) { free(ptrs); a->entries = nullptr; return; } - a->entries = safeCalloc(count, sizeof(AudioEntry)); + a->entries = (AudioEntry *)safeCalloc(count, sizeof(AudioEntry)); repeat(count, i) { if (ptrs[i] == 0) continue; BinaryReader_seek(reader, ptrs[i]); @@ -2428,7 +2428,7 @@ static void parseAUDO(BinaryReader* reader, DataWin* dw) { a->entries[i].dataOffset = (uint32_t)BinaryReader_getPosition(reader); // Load audio data into owned buffer if (a->entries[i].dataSize > 0) { - a->entries[i].data = safeMalloc(a->entries[i].dataSize); + a->entries[i].data = (uint8_t *)safeMalloc(a->entries[i].dataSize); BinaryReader_readBytes(reader, a->entries[i].data, a->entries[i].dataSize); } else { a->entries[i].data = nullptr; @@ -2463,7 +2463,7 @@ DataWin* DataWin_parse(const char* filePath, DataWinParserOptions options) { size_t fileSize = (size_t) fileSizeRaw; // Allocate and zero-initialize DataWin - DataWin* dw = safeCalloc(1, sizeof(DataWin)); + DataWin* dw = (DataWin *)safeCalloc(1, sizeof(DataWin)); BinaryReader reader = BinaryReader_create(file, (size_t) fileSize); @@ -2472,7 +2472,7 @@ DataWin* DataWin_parse(const char* filePath, DataWinParserOptions options) { // (we don't do that by default because some low end platforms would NOT be able to handle it) uint8_t* wholeFileData = nullptr; if (options.loadType == DATAWINLOADTYPE_LOAD_IN_MEMORY_AHEAD_OF_TIME) { - wholeFileData = safeMalloc((size_t) fileSize); + wholeFileData = (uint8_t *)safeMalloc((size_t) fileSize); safeFread(wholeFileData, fileSize, file, filePath); BinaryReader_setBuffer(&reader, wholeFileData, 0, (size_t) fileSize); } @@ -2590,7 +2590,7 @@ DataWin* DataWin_parse(const char* filePath, DataWinParserOptions options) { // Bulk-read the chunk data into memory for fast parsing uint8_t* chunkBuffer = nullptr; if (shouldParse && chunkLength > 0 && options.loadType != DATAWINLOADTYPE_LOAD_IN_MEMORY_AHEAD_OF_TIME) { - chunkBuffer = safeMalloc(chunkLength); + chunkBuffer = (uint8_t *)safeMalloc(chunkLength); size_t read = fread(chunkBuffer, 1, chunkLength, reader.file); if (read != chunkLength) { fprintf(stderr, "DataWin: short read on chunk %.4s (expected %u, got %zu)\n", chunkName, chunkLength, read); @@ -2988,7 +2988,7 @@ uint32_t DataWin_allocSpriteSlot(DataWin* dw, uint32_t startIndex) { } newIndex = dw->sprt.count; dw->sprt.count++; - dw->sprt.sprites = safeRealloc(dw->sprt.sprites, dw->sprt.count * sizeof(Sprite)); + dw->sprt.sprites = (Sprite *)safeRealloc(dw->sprt.sprites, dw->sprt.count * sizeof(Sprite)); memset(&dw->sprt.sprites[newIndex], 0, sizeof(Sprite)); assignName: // Match the native runner: set a "__newsprite" name so asset_get_index can find it. diff --git a/src/desktop/main.c b/src/desktop/main.c index e57100ec9..304295e88 100644 --- a/src/desktop/main.c +++ b/src/desktop/main.c @@ -763,7 +763,7 @@ static void writeFramebufferAsPng(GLuint fbo, int width, int height, const char* glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo); int stride = width * 4; - unsigned char* pixels = safeMalloc(stride * height); + unsigned char* pixels = (unsigned char *)safeMalloc(stride * height); if (pixels == nullptr) { fprintf(stderr, "Error: Failed to allocate memory for %s (%dx%d)\n", logPrefix, width, height); return; @@ -990,8 +990,8 @@ int main(int argc, char* argv[]) { #ifdef ENABLE_VM_OPCODE_PROFILER vm->opcodeProfilerEnabled = args.opcodeProfiler; if (vm->opcodeProfilerEnabled) { - vm->opcodeVariantCounts = safeCalloc(256 * 256, sizeof(uint64_t)); - vm->opcodeRValueTypeCounts = safeCalloc(256 * 256, sizeof(uint64_t)); + vm->opcodeVariantCounts = (uint64_t *)safeCalloc(256 * 256, sizeof(uint64_t)); + vm->opcodeRValueTypeCounts = (uint64_t *)safeCalloc(256 * 256, sizeof(uint64_t)); } #endif @@ -1186,7 +1186,7 @@ int main(int argc, char* argv[]) { lastSlash = lastBackslash; if (lastSlash != nullptr) { size_t len = (size_t) (lastSlash - args.dataWinPath + 1); - dataWinDir = safeMalloc(len + 1); + dataWinDir = (char *)safeMalloc(len + 1); memcpy(dataWinDir, args.dataWinPath, len); dataWinDir[len] = '\0'; } else { @@ -1535,9 +1535,9 @@ int main(int argc, char* argv[]) { printf("Changed global.interact [%d] value!\n", interactVarId); } - bool* currentKeyDown = safeCalloc(GML_KEY_COUNT, sizeof(bool)); - bool* currentKeyPressed = safeCalloc(GML_KEY_COUNT, sizeof(bool)); - bool* currentKeyReleased = safeCalloc(GML_KEY_COUNT, sizeof(bool)); + bool* currentKeyDown = (bool *)safeCalloc(GML_KEY_COUNT, sizeof(bool)); + bool* currentKeyPressed = (bool *)safeCalloc(GML_KEY_COUNT, sizeof(bool)); + bool* currentKeyReleased = (bool *)safeCalloc(GML_KEY_COUNT, sizeof(bool)); if (freeCamActive) { // THIS IS A HACK!! We don't want to pass keys to the runner, but we DO want to keep it so we can hold the arrow keys to move the camera @@ -1824,7 +1824,7 @@ int main(int argc, char* argv[]) { // The pendingWorkingDirectory contains a slash at the beginning of it (example: /chapter3) // The parentDir does NOT have a trailing slash, so we don't need to bother with it size_t newPathLen = strlen(parentDir) + strlen(nextWorkingDirectory) + 1 + strlen(dataWinFilename) + 1; - char* newPath = safeMalloc(newPathLen); + char* newPath = (char *)safeMalloc(newPathLen); snprintf(newPath, newPathLen, "%s%s/%s", parentDir, nextWorkingDirectory, dataWinFilename); free(parentDir); diff --git a/src/event_table.c b/src/event_table.c index 06f8b8ade..74bccab96 100644 --- a/src/event_table.c +++ b/src/event_table.c @@ -36,7 +36,7 @@ void EventSlotMap_build(EventSlotMap* outMap, DataWin* dw) { int32_t maxSub = outMap->maxSubtypeByType[t]; if (0 > maxSub) continue; size_t entryCount = (size_t)(maxSub + 1); - outMap->denseLookup[t] = safeMalloc(entryCount * sizeof(int16_t)); + outMap->denseLookup[t] = (int16_t *)safeMalloc(entryCount * sizeof(int16_t)); repeat(entryCount, i) outMap->denseLookup[t][i] = -1; } @@ -128,10 +128,10 @@ void ResolvedEventTable_build(ResolvedEventTable* outTable, DataWin* dw, const E outTable->totalEntries = 0; // Pass 1: count resolved entries per object so we can allocate flat arrays. - int32_t* scratchCodeId = safeMalloc((size_t) slotCount * sizeof(int32_t)); - int16_t* scratchOwner = safeMalloc((size_t) slotCount * sizeof(int16_t)); + int32_t* scratchCodeId = (int32_t *)safeMalloc((size_t) slotCount * sizeof(int32_t)); + int16_t* scratchOwner = (int16_t *)safeMalloc((size_t) slotCount * sizeof(int16_t)); - outTable->byObjectStart = safeMalloc((size_t)(objectCount + 1) * sizeof(uint32_t)); + outTable->byObjectStart = (uint32_t *)safeMalloc((size_t)(objectCount + 1) * sizeof(uint32_t)); outTable->byObjectStart[0] = 0; uint32_t totalEntries = 0; @@ -145,7 +145,7 @@ void ResolvedEventTable_build(ResolvedEventTable* outTable, DataWin* dw, const E outTable->totalEntries = totalEntries; // Pass 2: fill byObject. Walking slots in ascending order means each object's range is already sorted by slot (no extra qsort needed). - outTable->byObject = safeMalloc((size_t) totalEntries * sizeof(ObjectEventEntry)); + outTable->byObject = (ObjectEventEntry *)safeMalloc((size_t) totalEntries * sizeof(ObjectEventEntry)); uint32_t cursor = 0; repeat(objectCount, oi) { @@ -163,7 +163,7 @@ void ResolvedEventTable_build(ResolvedEventTable* outTable, DataWin* dw, const E free(scratchOwner); // Pass 3: histogram + prefix sum + scatter to build bySlot. Walking byObject in object-major order means each slot's range ends up sorted by concreteObjectId for free. - outTable->bySlotStart = safeMalloc((size_t)(slotCount + 1) * sizeof(uint32_t)); + outTable->bySlotStart = (uint32_t *)safeMalloc((size_t)(slotCount + 1) * sizeof(uint32_t)); repeat(slotCount + 1, i) outTable->bySlotStart[i] = 0; repeat(totalEntries, i) { outTable->bySlotStart[outTable->byObject[i].slot + 1]++; @@ -172,8 +172,8 @@ void ResolvedEventTable_build(ResolvedEventTable* outTable, DataWin* dw, const E outTable->bySlotStart[s + 1] += outTable->bySlotStart[s]; } - outTable->bySlot = safeMalloc((size_t) totalEntries * sizeof(SlotResponderEntry)); - uint32_t* slotCursor = safeMalloc((size_t) slotCount * sizeof(uint32_t)); + outTable->bySlot = (SlotResponderEntry *)safeMalloc((size_t) totalEntries * sizeof(SlotResponderEntry)); + uint32_t* slotCursor = (uint32_t *)safeMalloc((size_t) slotCount * sizeof(uint32_t)); memset(slotCursor, 0, (size_t) slotCount * sizeof(uint32_t)); repeat(objectCount, oi) { diff --git a/src/gl/gl_renderer.c b/src/gl/gl_renderer.c index accb6efe9..195b1675a 100644 --- a/src/gl/gl_renderer.c +++ b/src/gl/gl_renderer.c @@ -214,7 +214,7 @@ static bool compileProgram(GMLShader* gmlShader, const char* name, const char* v glGetProgramiv(shaderId, GL_ACTIVE_UNIFORMS, &uniformCount); gmlShader->uniformCount = uniformCount; - gmlShader->uniforms = safeCalloc(uniformCount, sizeof(GLShaderUniform)); + gmlShader->uniforms = (GLShaderUniform *)safeCalloc(uniformCount, sizeof(GLShaderUniform)); // We can only get the length of a specific uniform in OpenGL 4.3+... GLint maxUniformNameLength = 0; @@ -225,7 +225,7 @@ static bool compileProgram(GMLShader* gmlShader, const char* name, const char* v GLint size = 0; GLenum type = 0; - char* uniformName = safeMalloc(maxUniformNameLength + 1); + char* uniformName = (char *)safeMalloc(maxUniformNameLength + 1); glGetActiveUniform(shaderId, b, maxUniformNameLength, &length, &size, &type, uniformName); @@ -250,7 +250,7 @@ static void glInit(Renderer* renderer, DataWin* dataWin) { GLRenderer* gl = (GLRenderer*) renderer; renderer->dataWin = dataWin; - GMLShader* defaultShader = safeCalloc(1, sizeof(GMLShader)); + GMLShader* defaultShader = (GMLShader *)safeCalloc(1, sizeof(GMLShader)); bool success = compileProgram(defaultShader, "default", defaultVertexShaderSource, defaultFragmentShaderSource, 0, nullptr); if (!success) { fprintf(stderr, "GL: Failed to compile default shaders! Bailing..."); @@ -259,7 +259,7 @@ static void glInit(Renderer* renderer, DataWin* dataWin) { gl->defaultShaderProgram = defaultShader; - gl->gmlShaders = safeCalloc(dataWin->shdr.count, sizeof(GMLShader)); + gl->gmlShaders = (GMLShader *)safeCalloc(dataWin->shdr.count, sizeof(GMLShader)); fprintf(stderr, "GL: %u Shaders Found\n", dataWin->shdr.count); repeat(dataWin->shdr.count, i) { @@ -319,7 +319,7 @@ static void glInit(Renderer* renderer, DataWin* dataWin) { // EBO: pre-fill with quad index pattern (0,1,2,2,3,0 repeated) int32_t eboSize = MAX_QUADS * INDICES_PER_QUAD * (int32_t) sizeof(uint32_t); - uint32_t* indices = safeMalloc(eboSize); + uint32_t* indices = (uint32_t *)safeMalloc(eboSize); for (int32_t i = 0; MAX_QUADS > i; i++) { uint32_t base = (uint32_t) i * 4; indices[i * 6 + 0] = base + 0; @@ -345,14 +345,14 @@ static void glInit(Renderer* renderer, DataWin* dataWin) { glBindVertexArray(0); // Allocate CPU-side vertex buffer - gl->vertexData = safeMalloc(MAX_QUADS * VERTICES_PER_QUAD * FLOATS_PER_VERTEX * sizeof(float)); + gl->vertexData = (float *)safeMalloc(MAX_QUADS * VERTICES_PER_QUAD * FLOATS_PER_VERTEX * sizeof(float)); // Prepare texture slots for lazy loading (PNG decode deferred to first use) gl->textureCount = dataWin->txtr.count; - gl->glTextures = safeMalloc(gl->textureCount * sizeof(GLuint)); - gl->textureWidths = safeMalloc(gl->textureCount * sizeof(int32_t)); - gl->textureHeights = safeMalloc(gl->textureCount * sizeof(int32_t)); - gl->textureLoaded = safeMalloc(gl->textureCount * sizeof(bool)); + gl->glTextures = (GLuint *)safeMalloc(gl->textureCount * sizeof(GLuint)); + gl->textureWidths = (int32_t *)safeMalloc(gl->textureCount * sizeof(int32_t)); + gl->textureHeights = (int32_t *)safeMalloc(gl->textureCount * sizeof(int32_t)); + gl->textureLoaded = (bool *)safeMalloc(gl->textureCount * sizeof(bool)); glGenTextures((GLsizei) gl->textureCount, gl->glTextures); @@ -1834,10 +1834,10 @@ static uint32_t findOrAllocTexturePageSlot(GLRenderer* gl) { // No free slot found, grow the arrays uint32_t newPageId = gl->textureCount; gl->textureCount++; - gl->glTextures = safeRealloc(gl->glTextures, gl->textureCount * sizeof(GLuint)); - gl->textureWidths = safeRealloc(gl->textureWidths, gl->textureCount * sizeof(int32_t)); - gl->textureHeights = safeRealloc(gl->textureHeights, gl->textureCount * sizeof(int32_t)); - gl->textureLoaded = safeRealloc(gl->textureLoaded, gl->textureCount * sizeof(bool)); + gl->glTextures = (GLuint *)safeRealloc(gl->glTextures, gl->textureCount * sizeof(GLuint)); + gl->textureWidths = (int32_t *)safeRealloc(gl->textureWidths, gl->textureCount * sizeof(int32_t)); + gl->textureHeights = (int32_t *)safeRealloc(gl->textureHeights, gl->textureCount * sizeof(int32_t)); + gl->textureLoaded = (bool *)safeRealloc(gl->textureLoaded, gl->textureCount * sizeof(bool)); gl->glTextures[newPageId] = 0; gl->textureWidths[newPageId] = 0; gl->textureHeights[newPageId] = 0; @@ -1852,7 +1852,7 @@ static uint32_t findOrAllocTpagSlot(DataWin* dw, uint32_t originalTpagCount) { } uint32_t newIndex = dw->tpag.count; dw->tpag.count++; - dw->tpag.items = safeRealloc(dw->tpag.items, dw->tpag.count * sizeof(TexturePageItem)); + dw->tpag.items = (TexturePageItem *)safeRealloc(dw->tpag.items, dw->tpag.count * sizeof(TexturePageItem)); memset(&dw->tpag.items[newIndex], 0, sizeof(TexturePageItem)); dw->tpag.items[newIndex].texturePageId = -1; return newIndex; @@ -2111,7 +2111,7 @@ static int32_t glCreateSpriteFromSurface(Renderer* renderer, int32_t surfaceID, glBindFramebuffer(GL_READ_FRAMEBUFFER, gl->surfaces[surfaceID]); - uint8_t* pixels = safeMalloc((size_t) w * (size_t) h * 4); + uint8_t* pixels = (uint8_t *)safeMalloc((size_t) w * (size_t) h * 4); if (pixels == nullptr) return -1; glReadPixels(x, y, w, h, GL_RGBA, GL_UNSIGNED_BYTE, pixels); @@ -2157,7 +2157,7 @@ static int32_t glCreateSpriteFromSurface(Renderer* renderer, int32_t surfaceID, sprite->originX = xorig; sprite->originY = yorig; sprite->textureCount = 1; - sprite->tpagIndices = safeMalloc(sizeof(int32_t)); + sprite->tpagIndices = (int32_t *)safeMalloc(sizeof(int32_t)); sprite->tpagIndices[0] = (int32_t) tpagIndex; sprite->maskCount = 0; sprite->masks = nullptr; @@ -2487,7 +2487,7 @@ static RendererVtable glVtable; // ===[ Public API ]=== Renderer* GLRenderer_create(void) { - GLRenderer* gl = safeCalloc(1, sizeof(GLRenderer)); + GLRenderer* gl = (GLRenderer *)safeCalloc(1, sizeof(GLRenderer)); gl->base.vtable = &glVtable; glVtable.init = glInit; glVtable.destroy = glDestroy; diff --git a/src/gl_common/gl_common.c b/src/gl_common/gl_common.c index a63cd6d51..0dad8dbf5 100644 --- a/src/gl_common/gl_common.c +++ b/src/gl_common/gl_common.c @@ -50,10 +50,10 @@ uint32_t GLCommon_findOrAllocateSurfaceSlot(GLuint** surfaces, GLuint** surfaceT uint32_t newIndex = *count; (*count)++; - *surfaces = safeRealloc(*surfaces, *count * sizeof(GLuint)); - *surfaceTexture = safeRealloc(*surfaceTexture, *count * sizeof(GLuint)); - *surfaceWidth = safeRealloc(*surfaceWidth, *count * sizeof(int32_t)); - *surfaceHeight = safeRealloc(*surfaceHeight, *count * sizeof(int32_t)); + *surfaces = (GLuint *)safeRealloc(*surfaces, *count * sizeof(GLuint)); + *surfaceTexture = (GLuint *)safeRealloc(*surfaceTexture, *count * sizeof(GLuint)); + *surfaceWidth = (int32_t *)safeRealloc(*surfaceWidth, *count * sizeof(int32_t)); + *surfaceHeight = (int32_t *)safeRealloc(*surfaceHeight, *count * sizeof(int32_t)); (*surfaces)[newIndex] = 0; (*surfaceTexture)[newIndex] = 0; (*surfaceWidth)[newIndex] = 0; @@ -125,7 +125,7 @@ bool GLCommon_surfaceGetPixels(GLuint* surfaces, int32_t* surfaceWidth, int32_t* glBindFramebuffer(GL_FRAMEBUFFER, surfaces[surfaceId]); glPixelStorei(GL_PACK_ALIGNMENT, 1); - uint8_t* tmp = safeMalloc((size_t) w * (size_t) h * 4); + uint8_t* tmp = (uint8_t *)safeMalloc((size_t) w * (size_t) h * 4); glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, tmp); // OpenGL reads bottom-up; native expects y=0 at the top diff --git a/src/gl_legacy/gl_legacy_renderer.c b/src/gl_legacy/gl_legacy_renderer.c index cbba9f0a4..1ed8ba308 100644 --- a/src/gl_legacy/gl_legacy_renderer.c +++ b/src/gl_legacy/gl_legacy_renderer.c @@ -74,10 +74,10 @@ static void glInit(Renderer* renderer, DataWin* dataWin) { #else gl->textureCount = dataWin->txtr.count; #endif - gl->glTextures = safeMalloc(gl->textureCount * sizeof(GLuint)); - gl->textureWidths = safeMalloc(gl->textureCount * sizeof(int32_t)); - gl->textureHeights = safeMalloc(gl->textureCount * sizeof(int32_t)); - gl->textureLoaded = safeMalloc(gl->textureCount * sizeof(bool)); + gl->glTextures = (GLuint *)safeMalloc(gl->textureCount * sizeof(GLuint)); + gl->textureWidths = (int32_t *)safeMalloc(gl->textureCount * sizeof(int32_t)); + gl->textureHeights = (int32_t *)safeMalloc(gl->textureCount * sizeof(int32_t)); + gl->textureLoaded = (bool *)safeMalloc(gl->textureCount * sizeof(bool)); glGenTextures((GLsizei) gl->textureCount, gl->glTextures); @@ -1201,10 +1201,10 @@ static uint32_t findOrAllocTexturePageSlot(GLLegacyRenderer* gl) { // No free slot found, grow the arrays uint32_t newPageId = gl->textureCount; gl->textureCount++; - gl->glTextures = safeRealloc(gl->glTextures, gl->textureCount * sizeof(GLuint)); - gl->textureWidths = safeRealloc(gl->textureWidths, gl->textureCount * sizeof(int32_t)); - gl->textureHeights = safeRealloc(gl->textureHeights, gl->textureCount * sizeof(int32_t)); - gl->textureLoaded = safeRealloc(gl->textureLoaded, gl->textureCount * sizeof(bool)); + gl->glTextures = (GLuint *)safeRealloc(gl->glTextures, gl->textureCount * sizeof(GLuint)); + gl->textureWidths = (int32_t *)safeRealloc(gl->textureWidths, gl->textureCount * sizeof(int32_t)); + gl->textureHeights = (int32_t *)safeRealloc(gl->textureHeights, gl->textureCount * sizeof(int32_t)); + gl->textureLoaded = (bool *)safeRealloc(gl->textureLoaded, gl->textureCount * sizeof(bool)); gl->glTextures[newPageId] = 0; gl->textureWidths[newPageId] = 0; gl->textureHeights[newPageId] = 0; @@ -1219,7 +1219,7 @@ static uint32_t findOrAllocTpagSlot(DataWin* dw, uint32_t originalTpagCount) { } uint32_t newIndex = dw->tpag.count; dw->tpag.count++; - dw->tpag.items = safeRealloc(dw->tpag.items, dw->tpag.count * sizeof(TexturePageItem)); + dw->tpag.items = (TexturePageItem *)safeRealloc(dw->tpag.items, dw->tpag.count * sizeof(TexturePageItem)); memset(&dw->tpag.items[newIndex], 0, sizeof(TexturePageItem)); dw->tpag.items[newIndex].texturePageId = -1; return newIndex; @@ -1238,7 +1238,7 @@ static int32_t glCreateSpriteFromSurface(Renderer* renderer, int32_t surfaceID, glBindFramebuffer(GL_READ_FRAMEBUFFER, gl->surfaces[surfaceID]); - uint8_t* pixels = safeMalloc((size_t) w * (size_t) h * 4); + uint8_t* pixels = (uint8_t *)safeMalloc((size_t) w * (size_t) h * 4); if (pixels == nullptr) return -1; @@ -1285,7 +1285,7 @@ static int32_t glCreateSpriteFromSurface(Renderer* renderer, int32_t surfaceID, sprite->originX = xorig; sprite->originY = yorig; sprite->textureCount = 1; - sprite->tpagIndices = safeMalloc(sizeof(int32_t)); + sprite->tpagIndices = (int32_t *)safeMalloc(sizeof(int32_t)); sprite->tpagIndices[0] = (int32_t) tpagIndex; sprite->maskCount = 0; sprite->masks = nullptr; @@ -1693,7 +1693,7 @@ static RendererVtable glVtable; // ===[ Public API ]=== Renderer* GLLegacyRenderer_create(void) { - GLLegacyRenderer* gl = safeCalloc(1, sizeof(GLLegacyRenderer)); + GLLegacyRenderer* gl = (GLLegacyRenderer *)safeCalloc(1, sizeof(GLLegacyRenderer)); gl->base.vtable = &glVtable; glVtable.init = glInit; glVtable.destroy = glDestroy; diff --git a/src/gml_array.c b/src/gml_array.c index e1c79370e..5808b00e3 100644 --- a/src/gml_array.c +++ b/src/gml_array.c @@ -9,7 +9,7 @@ static void ensureRowCapacity(GMLArray* arr, int32_t minRows) { if (arr->rowCapacity >= minRows) return; int32_t newCap = arr->rowCapacity > 0 ? arr->rowCapacity : 4; while (minRows > newCap) newCap *= 2; - arr->rows = safeRealloc(arr->rows, (uint32_t) newCap * sizeof(GMLArrayRow)); + arr->rows = (GMLArrayRow *)safeRealloc(arr->rows, (uint32_t) newCap * sizeof(GMLArrayRow)); memset(arr->rows + arr->rowCapacity, 0, (newCap - arr->rowCapacity) * sizeof(GMLArrayRow)); arr->rowCapacity = newCap; } @@ -19,7 +19,7 @@ static void growRow(GMLArrayRow* row, int32_t minLength) { if (minLength > row->capacity) { int32_t newCap = row->capacity > 0 ? row->capacity : 4; while (minLength > newCap) newCap *= 2; - row->data = safeRealloc(row->data, (uint32_t) newCap * sizeof(RValue)); + row->data = (RValue *)safeRealloc(row->data, (uint32_t) newCap * sizeof(RValue)); row->capacity = newCap; } // GameMaker fills uninitialized array slots with 0 (real). @@ -31,7 +31,7 @@ static void growRow(GMLArrayRow* row, int32_t minLength) { } GMLArray* GMLArray_create(int32_t initialLength) { - GMLArray* arr = safeCalloc(1, sizeof(GMLArray)); + GMLArray* arr = (GMLArray *)safeCalloc(1, sizeof(GMLArray)); arr->refCount = 1; arr->owner = nullptr; if (initialLength > 0) { @@ -66,7 +66,7 @@ void GMLArray_decRef(GMLArray* arr) { GMLArray* GMLArray_clone(GMLArray* src, void* newOwner) { if (src == nullptr) return nullptr; - GMLArray* dst = safeCalloc(1, sizeof(GMLArray)); + GMLArray* dst = (GMLArray *)safeCalloc(1, sizeof(GMLArray)); dst->refCount = 1; dst->owner = newOwner; if (src->rowCount > 0) { diff --git a/src/gml_method.c b/src/gml_method.c index 60afe2777..79d86f3c1 100644 --- a/src/gml_method.c +++ b/src/gml_method.c @@ -4,7 +4,7 @@ #include GMLMethod* GMLMethod_create(int32_t codeIndex, int32_t boundInstanceId) { - GMLMethod* m = safeCalloc(1, sizeof(GMLMethod)); + GMLMethod* m = (GMLMethod *)safeCalloc(1, sizeof(GMLMethod)); m->refCount = 1; m->codeIndex = codeIndex; m->boundInstanceId = boundInstanceId; @@ -12,7 +12,7 @@ GMLMethod* GMLMethod_create(int32_t codeIndex, int32_t boundInstanceId) { } GMLMethod* GMLMethod_createBuiltin(BuiltinFunc builtin, int32_t boundInstanceId) { - GMLMethod* m = safeCalloc(1, sizeof(GMLMethod)); + GMLMethod* m = (GMLMethod *)safeCalloc(1, sizeof(GMLMethod)); m->refCount = 1; m->codeIndex = -1; m->boundInstanceId = boundInstanceId; @@ -21,7 +21,7 @@ GMLMethod* GMLMethod_createBuiltin(BuiltinFunc builtin, int32_t boundInstanceId) } GMLMethod* GMLMethod_createUnresolved(const char* name, int32_t boundInstanceId) { - GMLMethod* m = safeCalloc(1, sizeof(GMLMethod)); + GMLMethod* m = (GMLMethod *)safeCalloc(1, sizeof(GMLMethod)); m->refCount = 1; m->codeIndex = -1; m->boundInstanceId = boundInstanceId; diff --git a/src/ini.c b/src/ini.c index a843edd08..44afa5fb4 100644 --- a/src/ini.c +++ b/src/ini.c @@ -30,7 +30,7 @@ static int findKeyIndex(const IniSection* section, const char* key) { static IniSection* addSection(IniFile* ini, const char* name) { if (ini->count >= ini->capacity) { ini->capacity = (ini->capacity == 0) ? 4 : ini->capacity * 2; - ini->sections = safeRealloc(ini->sections, (size_t) ini->capacity * sizeof(IniSection)); + ini->sections = (IniSection *)safeRealloc(ini->sections, (size_t) ini->capacity * sizeof(IniSection)); } IniSection* section = &ini->sections[ini->count++]; section->name = safeStrdup(name); @@ -44,8 +44,8 @@ static IniSection* addSection(IniFile* ini, const char* name) { static void addKeyValue(IniSection* section, const char* key, const char* value) { if (section->count >= section->capacity) { section->capacity = (section->capacity == 0) ? 4 : section->capacity * 2; - section->keys = safeRealloc(section->keys, (size_t) section->capacity * sizeof(char*)); - section->values = safeRealloc(section->values, (size_t) section->capacity * sizeof(char*)); + section->keys = (char **)safeRealloc(section->keys, (size_t) section->capacity * sizeof(char*)); + section->values = (char **)safeRealloc(section->values, (size_t) section->capacity * sizeof(char*)); } section->keys[section->count] = safeStrdup(key); section->values[section->count] = safeStrdup(value); @@ -72,7 +72,7 @@ static char* normalizeValue(char* value) { // ===[ Lifecycle ]=== IniFile* Ini_parse(const char* text) { - IniFile* ini = safeCalloc(1, sizeof(IniFile)); + IniFile* ini = (IniFile *)safeCalloc(1, sizeof(IniFile)); if (text == nullptr || *text == '\0') { return ini; @@ -267,7 +267,7 @@ void Ini_deleteSection(IniFile* ini, const char* section) { char* Ini_serialize(const IniFile* ini, size_t initialCapacity) { size_t capacity = initialCapacity; size_t length = 0; - char* buffer = safeMalloc(capacity); + char* buffer = (char *)safeMalloc(capacity); buffer[0] = '\0'; for (int i = 0; i < ini->count; ++i) { @@ -291,7 +291,7 @@ char* Ini_serialize(const IniFile* ini, size_t initialCapacity) { while (length + needed + 1 > capacity) { capacity *= 2; } - buffer = safeRealloc(buffer, capacity); + buffer = (char *)safeRealloc(buffer, capacity); // Write section header if (length > 0) { diff --git a/src/input_recording.c b/src/input_recording.c index 1c6cef814..674d60b79 100644 --- a/src/input_recording.c +++ b/src/input_recording.c @@ -11,7 +11,7 @@ #include "stb_ds.h" InputRecording* InputRecording_createRecorder(const char* filePath) { - InputRecording* rec = safeCalloc(1, sizeof(InputRecording)); + InputRecording* rec = (InputRecording *)safeCalloc(1, sizeof(InputRecording)); rec->isRecording = true; rec->recordFilePath = filePath; return rec; @@ -29,7 +29,7 @@ InputRecording* InputRecording_createPlayer(const char* playbackFilePath, const long fileSize = ftell(f); fseek(f, 0, SEEK_SET); - char* contents = safeMalloc(fileSize + 1); + char* contents = (char *)safeMalloc(fileSize + 1); safeFread(contents, fileSize, f, playbackFilePath); contents[fileSize] = '\0'; fclose(f); @@ -52,7 +52,7 @@ InputRecording* InputRecording_createPlayer(const char* playbackFilePath, const if (frameNum > maxFrame) maxFrame = frameNum; } - InputRecording* rec = safeCalloc(1, sizeof(InputRecording)); + InputRecording* rec = (InputRecording *)safeCalloc(1, sizeof(InputRecording)); rec->isPlayback = true; rec->playbackFrameCount = maxFrame + 1; @@ -63,7 +63,7 @@ InputRecording* InputRecording_createPlayer(const char* playbackFilePath, const } // Allocate playbackFrames array (one stb_ds int32_t array per frame) - rec->playbackFrames = safeCalloc(rec->playbackFrameCount, sizeof(InputFrame)); + rec->playbackFrames = (InputFrame *)safeCalloc(rec->playbackFrameCount, sizeof(InputFrame)); repeat(objectLen, i) { const char* key = JsonReader_getJsonKeyByIndex(root, i); diff --git a/src/instance.c b/src/instance.c index 9f81ed41e..4be8162bb 100644 --- a/src/instance.c +++ b/src/instance.c @@ -9,7 +9,7 @@ #include "int_rvalue_hashmap.h" Instance* Instance_create(uint32_t instanceId, int32_t objectIndex, GMLReal x, GMLReal y) { - Instance* inst = safeCalloc(1, sizeof(Instance)); + Instance* inst = (Instance *)safeCalloc(1, sizeof(Instance)); inst->instanceId = instanceId; inst->objectIndex = objectIndex; inst->refCount = 0; diff --git a/src/int_int_hashmap.c b/src/int_int_hashmap.c index 2f6f7cadb..ded85ff6f 100644 --- a/src/int_int_hashmap.c +++ b/src/int_int_hashmap.c @@ -7,7 +7,7 @@ static void allocEmpty(IntIntHashMap* map, uint32_t capacity) { // memset 0xFF makes every key int32_t = -1 (the empty sentinel). The value bytes also become 0xFF but are unread for empty slots, so no harm. - map->entries = safeMalloc(capacity * sizeof(IntIntEntry)); + map->entries = (IntIntEntry *)safeMalloc(capacity * sizeof(IntIntEntry)); memset(map->entries, 0xFF, capacity * sizeof(IntIntEntry)); map->capacity = capacity; map->mask = capacity - 1; diff --git a/src/int_rvalue_hashmap.c b/src/int_rvalue_hashmap.c index cccb7803e..03ae46a6a 100644 --- a/src/int_rvalue_hashmap.c +++ b/src/int_rvalue_hashmap.c @@ -7,7 +7,7 @@ static void allocEmpty(IntRValueHashMap* map, uint32_t capacity) { // memset 0xFF makes every key int32_t = -1 (the empty sentinel). The value bytes also become 0xFF but are unread for empty slots, so no harm. - map->entries = safeMalloc(capacity * sizeof(IntRValueEntry)); + map->entries = (IntRValueEntry *)safeMalloc(capacity * sizeof(IntRValueEntry)); memset(map->entries, 0xFF, capacity * sizeof(IntRValueEntry)); map->capacity = capacity; map->mask = capacity - 1; diff --git a/src/json_reader.c b/src/json_reader.c index 3dd90942e..f53185f78 100644 --- a/src/json_reader.c +++ b/src/json_reader.c @@ -38,7 +38,7 @@ static char advance(JsonParser* parser) { } static JsonValue* makeValue(JsonValueType type) { - JsonValue* value = safeCalloc(1, sizeof(JsonValue)); + JsonValue* value = (JsonValue *)safeCalloc(1, sizeof(JsonValue)); if (value == nullptr) { fprintf(stderr, "JsonReader: calloc failed\n"); abort(); @@ -56,7 +56,7 @@ static JsonValue* parseString(JsonParser* parser) { size_t capacity = 64; size_t length = 0; - char* buffer = safeMalloc(capacity); + char* buffer = (char *)safeMalloc(capacity); if (buffer == nullptr) { fprintf(stderr, "JsonReader: malloc failed\n"); abort(); @@ -99,14 +99,14 @@ static JsonValue* parseString(JsonParser* parser) { } else if (2048 > codePoint) { if (length + 2 >= capacity) { capacity *= 2; - buffer = safeRealloc(buffer, capacity); + buffer = (char *)safeRealloc(buffer, capacity); } buffer[length++] = (char) (0xC0 | (codePoint >> 6)); c = (char) (0x80 | (codePoint & 0x3F)); } else { if (length + 3 >= capacity) { capacity *= 2; - buffer = safeRealloc(buffer, capacity); + buffer = (char *)safeRealloc(buffer, capacity); } buffer[length++] = (char) (0xE0 | (codePoint >> 12)); buffer[length++] = (char) (0x80 | ((codePoint >> 6) & 0x3F)); @@ -124,7 +124,7 @@ static JsonValue* parseString(JsonParser* parser) { // Grow buffer if needed if (length + 1 >= capacity) { capacity *= 2; - buffer = safeRealloc(buffer, capacity); + buffer = (char *)safeRealloc(buffer, capacity); if (buffer == nullptr) { fprintf(stderr, "JsonReader: realloc failed\n"); abort(); @@ -180,7 +180,7 @@ static JsonValue* parseArray(JsonParser* parser) { // Grow items array if needed if (value->array.count >= value->array.capacity) { int newCapacity = (value->array.capacity == 0) ? 8 : value->array.capacity * 2; - value->array.items = safeRealloc(value->array.items, (size_t) newCapacity * sizeof(JsonValue)); + value->array.items = (JsonValue *)safeRealloc(value->array.items, (size_t) newCapacity * sizeof(JsonValue)); if (value->array.items == nullptr) { fprintf(stderr, "JsonReader: realloc failed\n"); abort(); @@ -259,8 +259,8 @@ static JsonValue* parseObject(JsonParser* parser) { // Grow arrays if needed if (value->object.count >= value->object.capacity) { int newCapacity = (value->object.capacity == 0) ? 8 : value->object.capacity * 2; - value->object.keys = safeRealloc(value->object.keys, (size_t) newCapacity * sizeof(char*)); - value->object.values = safeRealloc(value->object.values, (size_t) newCapacity * sizeof(JsonValue)); + value->object.keys = (char **)safeRealloc(value->object.keys, (size_t) newCapacity * sizeof(char*)); + value->object.values = (JsonValue *)safeRealloc(value->object.values, (size_t) newCapacity * sizeof(JsonValue)); if (value->object.keys == nullptr || value->object.values == nullptr) { fprintf(stderr, "JsonReader: realloc failed\n"); abort(); diff --git a/src/noop_audio_system.c b/src/noop_audio_system.c index 364faf61c..e17f96ed4 100644 --- a/src/noop_audio_system.c +++ b/src/noop_audio_system.c @@ -78,7 +78,7 @@ static bool noopDestroyStream(MAYBE_UNUSED AudioSystem* audio, MAYBE_UNUSED int3 static AudioSystemVtable noopVtable; NoopAudioSystem* NoopAudioSystem_create(void) { - NoopAudioSystem* audio = safeCalloc(1, sizeof(NoopAudioSystem)); + NoopAudioSystem* audio = (NoopAudioSystem *)safeCalloc(1, sizeof(NoopAudioSystem)); noopVtable.init = noopInit, noopVtable.destroy = noopDestroy, noopVtable.update = noopUpdate, diff --git a/src/noop_file_system.c b/src/noop_file_system.c index 05cf7637a..4aebf9a42 100644 --- a/src/noop_file_system.c +++ b/src/noop_file_system.c @@ -87,7 +87,7 @@ static bool noopReadFileBinary(FileSystem* fs, const char* relativePath, uint8_t return false; MemoryBinaryData* entry = &nfs->binaryFiles[idx].value; - uint8_t* copy = safeMalloc((size_t) entry->size); + uint8_t* copy = (uint8_t *)safeMalloc((size_t) entry->size); memcpy(copy, entry->data, (size_t) entry->size); *outData = copy; *outSize = entry->size; @@ -100,12 +100,12 @@ static bool noopWriteFileBinary(FileSystem* fs, const char* relativePath, const ptrdiff_t idx = shgeti(nfs->binaryFiles, relativePath); if (idx >= 0) { free(nfs->binaryFiles[idx].value.data); - uint8_t* copy = safeMalloc((size_t) size); + uint8_t* copy = (uint8_t *)safeMalloc((size_t) size); memcpy(copy, data, (size_t) size); nfs->binaryFiles[idx].value.data = copy; nfs->binaryFiles[idx].value.size = size; } else { - uint8_t* copy = safeMalloc((size_t) size); + uint8_t* copy = (uint8_t *)safeMalloc((size_t) size); memcpy(copy, data, (size_t) size); MemoryBinaryData binaryData = {0}; binaryData.data = copy; @@ -131,7 +131,7 @@ typedef struct { static void* noopBinaryOpen(FileSystem* fs, const char* relativePath, int32_t mode) { NoopFileSystem* nfs = (NoopFileSystem*) fs; - NoopBinaryHandle* h = safeCalloc(1, sizeof(NoopBinaryHandle)); + NoopBinaryHandle* h = (NoopBinaryHandle *)safeCalloc(1, sizeof(NoopBinaryHandle)); h->owner = nfs; h->path = safeStrdup(relativePath); h->writable = (mode != GML_FILE_BIN_READ); @@ -143,7 +143,7 @@ static void* noopBinaryOpen(FileSystem* fs, const char* relativePath, int32_t mo ptrdiff_t idx = shgeti(nfs->binaryFiles, relativePath); if (idx >= 0) { MemoryBinaryData* entry = &nfs->binaryFiles[idx].value; - h->buffer = safeMalloc((size_t) entry->size); + h->buffer = (uint8_t *)safeMalloc((size_t) entry->size); memcpy(h->buffer, entry->data, (size_t) entry->size); h->size = entry->size; h->capacity = entry->size; @@ -199,7 +199,7 @@ static int32_t noopBinaryWrite(MAYBE_UNUSED FileSystem* fs, void* handle, const if (needed > h->capacity) { int32_t newCap = h->capacity > 0 ? h->capacity : 64; while (newCap < needed) newCap *= 2; - h->buffer = safeRealloc(h->buffer, (size_t) newCap); + h->buffer = (uint8_t *)safeRealloc(h->buffer, (size_t) newCap); h->capacity = newCap; } if (h->position > h->size) { @@ -333,7 +333,7 @@ static FileSystemVtable noopFileSystemVtable; // ===[ Lifecycle ]=== FileSystem* NoopFileSystem_create(void) { - NoopFileSystem* nfs = safeCalloc(1, sizeof(NoopFileSystem)); + NoopFileSystem* nfs = (NoopFileSystem *)safeCalloc(1, sizeof(NoopFileSystem)); nfs->base.vtable = &noopFileSystemVtable; noopFileSystemVtable.resolvePath = noopResolvePath; noopFileSystemVtable.fileExists = noopFileExists; diff --git a/src/overlay_file_system.c b/src/overlay_file_system.c index 73560b938..92af147dc 100644 --- a/src/overlay_file_system.c +++ b/src/overlay_file_system.c @@ -47,7 +47,7 @@ static char* joinPath(const char* basePath, const char* normalizedPath) { } size_t baseLen = strlen(basePath); size_t relLen = strlen(normalizedPath); - char* full = safeMalloc(baseLen + relLen + 1); + char* full = (char *)safeMalloc(baseLen + relLen + 1); memcpy(full, basePath, baseLen); memcpy(full + baseLen, normalizedPath, relLen); full[baseLen + relLen] = '\0'; @@ -149,7 +149,7 @@ static char* overlayReadFileText(FileSystem* fs, const char* relativePath) { long size = ftell(f); fseek(f, 0, SEEK_SET); - char* content = safeMalloc((size_t) size + 1); + char* content = (char *)safeMalloc((size_t) size + 1); size_t bytesRead = fread(content, 1, (size_t) size, f); content[bytesRead] = '\0'; fclose(f); @@ -186,7 +186,7 @@ static bool overlayReadFileBinary(FileSystem* fs, const char* relativePath, uint long size = ftell(f); fseek(f, 0, SEEK_SET); - uint8_t* data = safeMalloc((size_t) size); + uint8_t* data = (uint8_t *)safeMalloc((size_t) size); size_t bytesRead = fread(data, 1, (size_t) size, f); fclose(f); @@ -216,7 +216,7 @@ typedef struct { } OverlayBinaryHandle; static OverlayBinaryHandle* overlayBinaryHandleNew(FILE* fp, char* fullPathTaken) { - OverlayBinaryHandle* h = safeMalloc(sizeof(OverlayBinaryHandle)); + OverlayBinaryHandle* h = (OverlayBinaryHandle *)safeMalloc(sizeof(OverlayBinaryHandle)); h->fp = fp; h->fullPath = fullPathTaken; // takes ownership return h; @@ -361,7 +361,7 @@ static void listSingleDir(FileSystemDirEntry** list, const char* fullDir) { bool isDir = false; size_t dirLen = strlen(fullDir); size_t nameLen = strlen(ent->d_name); - char* full = safeMalloc(dirLen + nameLen + 2); + char* full = (char *)safeMalloc(dirLen + nameLen + 2); memcpy(full, fullDir, dirLen); full[dirLen] = '/'; memcpy(full + dirLen + 1, ent->d_name, nameLen + 1); @@ -410,7 +410,7 @@ static char* withTrailingSlash(const char* path) { if (last == '\\') out[len - 1] = '/'; return out; } - char* out = safeMalloc(len + 2); + char* out = (char *)safeMalloc(len + 2); memcpy(out, path, len); out[len] = '/'; out[len + 1] = '\0'; @@ -418,7 +418,7 @@ static char* withTrailingSlash(const char* path) { } OverlayFileSystem* OverlayFileSystem_create(const char* bundlePath, const char* savePath) { - OverlayFileSystem* fs = safeCalloc(1, sizeof(OverlayFileSystem)); + OverlayFileSystem* fs = (OverlayFileSystem *)safeCalloc(1, sizeof(OverlayFileSystem)); fs->base.vtable = &overlayFileSystemVtable; overlayFileSystemVtable.resolvePath = overlayResolvePath; overlayFileSystemVtable.fileExists = overlayFileExists; diff --git a/src/profiler.c b/src/profiler.c index 8b0772153..97026066f 100644 --- a/src/profiler.c +++ b/src/profiler.c @@ -10,7 +10,7 @@ #include "gettime.h" Profiler* Profiler_create(void) { - Profiler* p = safeMalloc(sizeof(Profiler)); + Profiler* p = (Profiler *)safeMalloc(sizeof(Profiler)); p->entries = nullptr; p->frameDepth = 0; p->instructionCount = 0; diff --git a/src/runner.c b/src/runner.c index 50d5aa7a7..b00fa3212 100644 --- a/src/runner.c +++ b/src/runner.c @@ -202,7 +202,7 @@ static void executeCode(Runner* runner, Instance* instance, int32_t codeId) { // the nested execution overwrite the caller's stack slot values) RValue* savedStackValues = nullptr; if (savedStackTop > 0) { - savedStackValues = safeMalloc((uint32_t) savedStackTop * sizeof(RValue)); + savedStackValues = (RValue *)safeMalloc((uint32_t) savedStackTop * sizeof(RValue)); memcpy(savedStackValues, vm->stack.slots, (uint32_t) savedStackTop * sizeof(RValue)); } @@ -1447,7 +1447,7 @@ static void initRoom(Runner* runner, int32_t roomIndex) { RoomLayer* layerSource = &room->layers[i]; if (layerSource->type == RoomLayerType_Background && layerSource->backgroundData != nullptr) { RoomLayerBackgroundData* src = layerSource->backgroundData; - RuntimeBackgroundElement* bg = safeMalloc(sizeof(RuntimeBackgroundElement)); + RuntimeBackgroundElement* bg = (RuntimeBackgroundElement *)safeMalloc(sizeof(RuntimeBackgroundElement)); bg->spriteIndex = src->spriteIndex; bg->visible = src->visible; bg->hTiled = src->hTiled; @@ -1486,7 +1486,7 @@ static void initRoom(Runner* runner, int32_t roomIndex) { RuntimeLayer* runtimeLayer = &runner->runtimeLayers[i]; repeat(assets->spriteCount, j) { SpriteInstance* src = &assets->sprites[j]; - RuntimeSpriteElement* spriteElement = safeMalloc(sizeof(RuntimeSpriteElement)); + RuntimeSpriteElement* spriteElement = (RuntimeSpriteElement *)safeMalloc(sizeof(RuntimeSpriteElement)); spriteElement->name = src->name; spriteElement->spriteIndex = src->spriteIndex; spriteElement->x = src->x; @@ -1899,17 +1899,17 @@ void Runner_reset(Runner* runner) { runner->currentRoomIndex = -1; runner->currentRoomOrderPosition = -1; runner->nextInstanceId = runner->dataWin->gen8.lastObj + 1; - runner->savedRoomStates = safeCalloc(runner->dataWin->room.count, sizeof(SavedRoomState)); + runner->savedRoomStates = (SavedRoomState *)safeCalloc(runner->dataWin->room.count, sizeof(SavedRoomState)); runner->nextLayerId = 1; runner->audioSystem->vtable->stopAll(runner->audioSystem); // Allocate the per-object instance list array once. // We don't need to reinitialize the list because the objt.count is fixed for this data.win. if (runner->instancesByObject == nullptr) { - runner->instancesByObject = safeCalloc(runner->dataWin->objt.count, sizeof(Instance**)); + runner->instancesByObject = (Instance ***)safeCalloc(runner->dataWin->objt.count, sizeof(Instance**)); } if (runner->instancesByExactObject == nullptr) { - runner->instancesByExactObject = safeCalloc(runner->dataWin->objt.count, sizeof(Instance**)); + runner->instancesByExactObject = (Instance ***)safeCalloc(runner->dataWin->objt.count, sizeof(Instance**)); } // Reset builtin function state @@ -1940,7 +1940,7 @@ static int compareTargetObjectIndexAscending(const void *a, const void *b) { static void flattenCollisionEvents(Runner* runner) { DataWin* dataWin = runner->dataWin; int32_t count = (int32_t) dataWin->objt.count; - runner->flattenedCollisionEvents = safeCalloc((size_t) (count > 0 ? count : 1), sizeof(FlattenedCollisionEventList)); + runner->flattenedCollisionEvents = (FlattenedCollisionEventList *)safeCalloc((size_t) (count > 0 ? count : 1), sizeof(FlattenedCollisionEventList)); if (0 >= count) return; repeat(count, i) { @@ -1949,7 +1949,7 @@ static void flattenCollisionEvents(Runner* runner) { FlattenedCollisionEventList* dst = &runner->flattenedCollisionEvents[i]; if (src->eventCount > 0) { - dst->events = safeMalloc(src->eventCount * sizeof(FlattenedCollisionEvent)); + dst->events = (FlattenedCollisionEvent *)safeMalloc(src->eventCount * sizeof(FlattenedCollisionEvent)); repeat(src->eventCount, e) { ObjectEvent* srcEvt = &src->events[e]; int32_t srcCodeId = (srcEvt->actionCount > 0) ? srcEvt->actions[0].codeId : -1; @@ -1979,7 +1979,7 @@ static void flattenCollisionEvents(Runner* runner) { int32_t ancCodeId = (ancEvt->actionCount > 0) ? ancEvt->actions[0].codeId : -1; uint32_t newCount = dst->eventCount + 1; - dst->events = safeRealloc(dst->events, newCount * sizeof(FlattenedCollisionEvent)); + dst->events = (FlattenedCollisionEvent *)safeRealloc(dst->events, newCount * sizeof(FlattenedCollisionEvent)); FlattenedCollisionEvent fce = {0}; fce.targetObjectIndex = target; fce.codeId = ancCodeId; @@ -1999,10 +1999,10 @@ static void flattenCollisionEvents(Runner* runner) { // Used by collision dispatch to skip non-collision objects in the outer loop, mirroring how the native obj_has_event table partitions instance iteration by event class. static void populateObjectsWithAnyEventOfType(Runner* runner) { int32_t objectCount = (int32_t) runner->dataWin->objt.count; - runner->objectsWithAnyEventOfType = safeCalloc(OBJT_EVENT_TYPE_COUNT, sizeof(int32_t*)); + runner->objectsWithAnyEventOfType = (int32_t **)safeCalloc(OBJT_EVENT_TYPE_COUNT, sizeof(int32_t*)); if (objectCount == 0) return; - uint8_t* seen = safeCalloc((size_t) objectCount, 1); + uint8_t* seen = (uint8_t *)safeCalloc((size_t) objectCount, 1); repeat(OBJT_EVENT_TYPE_COUNT, t) { int16_t* dense = runner->eventSlotMap.denseLookup[t]; @@ -2030,7 +2030,7 @@ static void populateObjectsWithAnyEventOfType(Runner* runner) { // Validates if all required renderer functions are not null static void validateRendererVtable(Renderer* renderer) { - RendererVtable* v = requireNotNull(renderer->vtable); + RendererVtable* v = (RendererVtable *)requireNotNull(renderer->vtable); #define requireNotNullFunction(fn) requireMessage(v->fn != nullptr, "Renderer " #fn " does not have a implementation!") requireNotNullFunction(init); @@ -2103,7 +2103,7 @@ Runner* Runner_create(DataWin* dataWin, VMContext* vm, Renderer* renderer, FileS requireNotNull(audioSystem); validateRendererVtable(renderer); - Runner* runner = safeCalloc(1, sizeof(Runner)); + Runner* runner = (Runner *)safeCalloc(1, sizeof(Runner)); runner->dataWin = dataWin; runner->vmContext = vm; runner->renderer = renderer; diff --git a/src/runner_gamepad.c b/src/runner_gamepad.c index 55c32ad13..99bb795f0 100644 --- a/src/runner_gamepad.c +++ b/src/runner_gamepad.c @@ -66,7 +66,7 @@ static int gmlAxisToIndex(int32_t gmlAxis) { } RunnerGamepadState* RunnerGamepad_create(void) { - RunnerGamepadState* gp = safeCalloc(1, sizeof(RunnerGamepadState)); + RunnerGamepadState* gp = (RunnerGamepadState *)safeCalloc(1, sizeof(RunnerGamepadState)); for (int i = 0; MAX_GAMEPADS > i; i++) { gp->slots[i].deadzone = 0.15f; gp->slots[i].triggerThreshold = 0.5f; @@ -212,4 +212,4 @@ int RunnerGamepad_getHatValue(RunnerGamepadState* gp, int device, int hat) { if (slot->buttonDown[13]) mask |= 4; if (slot->buttonDown[14]) mask |= 8; return mask; -} \ No newline at end of file +} diff --git a/src/runner_keyboard.c b/src/runner_keyboard.c index 5b77a8da8..646414667 100644 --- a/src/runner_keyboard.c +++ b/src/runner_keyboard.c @@ -9,7 +9,7 @@ static bool isValidKey(int32_t key) { } RunnerKeyboardState* RunnerKeyboard_create(void) { - RunnerKeyboardState* kb = safeCalloc(1, sizeof(RunnerKeyboardState)); + RunnerKeyboardState* kb = (RunnerKeyboardState *)safeCalloc(1, sizeof(RunnerKeyboardState)); kb->lastKey = VK_NOKEY; kb->lastChar[0] = 0; kb->lastChar[1] = 0; diff --git a/src/runner_mouse.c b/src/runner_mouse.c index 091743d6e..a18119239 100644 --- a/src/runner_mouse.c +++ b/src/runner_mouse.c @@ -15,7 +15,7 @@ static bool isValidButton(int32_t button) { } RunnerMouseState* RunnerMouse_create(void) { - RunnerMouseState* m = safeCalloc(1, sizeof(RunnerMouseState)); + RunnerMouseState* m = (RunnerMouseState *)safeCalloc(1, sizeof(RunnerMouseState)); return m; } diff --git a/src/rvalue.h b/src/rvalue.h index d79cc7a18..4e827f9bd 100644 --- a/src/rvalue.h +++ b/src/rvalue.h @@ -343,7 +343,7 @@ static inline char* RValue_toStringFancy(RValue val) { // length + quotes (2) + null terminator int newLength = strlen(valueAsString) + 3; - char* valueWithQuotes = safeCalloc(newLength, sizeof(char)); + char* valueWithQuotes = (char *)safeCalloc(newLength, sizeof(char)); snprintf(valueWithQuotes, newLength, "\"%s\"", valueAsString); free(valueAsString); @@ -376,7 +376,7 @@ static inline char* RValue_toStringTyped(RValue val) { case RVALUE_STRING: { const char* str = val.string != nullptr ? val.string : ""; size_t needed = strlen(str) + 3; - char* result = safeCalloc(needed, sizeof(char)); + char* result = (char *)safeCalloc(needed, sizeof(char)); snprintf(result, needed, "\"%s\"", str); return result; } diff --git a/src/spatial_grid.c b/src/spatial_grid.c index 5f61bdcb8..e3f9a31f4 100644 --- a/src/spatial_grid.c +++ b/src/spatial_grid.c @@ -6,7 +6,7 @@ #include "utils.h" SpatialGrid* SpatialGrid_create(uint32_t roomWidth, uint32_t roomHeight) { - SpatialGrid* grid = safeCalloc(1, sizeof(SpatialGrid)); + SpatialGrid* grid = (SpatialGrid *)safeCalloc(1, sizeof(SpatialGrid)); // +1 to avoid truncation uint32_t gridWidth = (roomWidth / SPATIAL_GRID_CELL_SIZE) + 1; @@ -18,7 +18,7 @@ SpatialGrid* SpatialGrid_create(uint32_t roomWidth, uint32_t roomHeight) { grid->gridWidth = gridWidth; grid->gridHeight = gridHeight; - grid->grid = safeCalloc(gridWidth * gridHeight, sizeof(Instance**)); + grid->grid = (Instance ***)safeCalloc(gridWidth * gridHeight, sizeof(Instance**)); return grid; } diff --git a/src/string_builder.c b/src/string_builder.c index a4818fee1..2b5728a1b 100644 --- a/src/string_builder.c +++ b/src/string_builder.c @@ -10,7 +10,7 @@ StringBuilder StringBuilder_create(size_t initialCapacity) { if (STRING_BUILDER_MIN_CAPACITY > initialCapacity) initialCapacity = STRING_BUILDER_MIN_CAPACITY; - char* buffer = safeMalloc(initialCapacity); + char* buffer = (char *)safeMalloc(initialCapacity); buffer[0] = '\0'; StringBuilder ret = {0}; ret.buffer = buffer; @@ -39,7 +39,7 @@ void StringBuilder_ensureCapacity(StringBuilder* sb, size_t additionalBytes) { while (required > newCapacity) { newCapacity *= 2; } - sb->buffer = safeRealloc(sb->buffer, newCapacity); + sb->buffer = (char *)safeRealloc(sb->buffer, newCapacity); sb->capacity = newCapacity; } diff --git a/src/text_utils.h b/src/text_utils.h index bc0d65635..a97269810 100644 --- a/src/text_utils.h +++ b/src/text_utils.h @@ -173,7 +173,7 @@ static inline PreprocessedText TextUtils_preprocessGmlText(const char* text) { for (int32_t i = 0; len > i; i++) { if (text[i] == '#') { // Found one - allocate and process from here - char* result = safeMalloc(len + 1); + char* result = (char *)safeMalloc(len + 1); memcpy(result, text, i); int32_t out = i; @@ -271,7 +271,7 @@ static inline PreprocessedText TextUtils_wrapText(Font* font, const char* text, int32_t linewidth = (0 > maxWidth) ? 10000000 : maxWidth; // means nothing will "wrap" // Worst case: each byte becomes itself plus a '\n' separator. - char* out = safeMalloc((size_t) len * 2 + 1); + char* out = (char *)safeMalloc((size_t) len * 2 + 1); int32_t outLen = 0; bool wroteAny = false; diff --git a/src/vm.c b/src/vm.c index 8d0018fb6..599ace8df 100644 --- a/src/vm.c +++ b/src/vm.c @@ -467,7 +467,7 @@ static uint32_t resolveLocalSlot(VMContext* ctx, int32_t varID) { // Grow this frame's localVars window to cover `slot` whether the entry is pre-existing or freshly allocated. // Pre-existing entries can still be past ctx->localVarCount if a nested call to the same code extended the slot map while the outer frame was suspended (the outer frame's localVarCount is captured at call entry and doesn't follow later growth). if (slot >= ctx->localVarCount) { - RValue* resizedLocalVars = safeCalloc(slot + 1, sizeof(RValue)); + RValue* resizedLocalVars = (RValue *)safeCalloc(slot + 1, sizeof(RValue)); memcpy(resizedLocalVars, ctx->localVars, sizeof(RValue) * ctx->localVarCount); free(ctx->localVars); ctx->localVars = resizedLocalVars; @@ -642,7 +642,7 @@ void VM_writeToScriptArgs(VMContext* ctx, int32_t writeIndex, RValue val) { // You CAN write to the builtin argumentX variables even though the function does not "have" it as a function argument // So we'll need to check if we need to resize the scriptArgs manually... if (writeIndex >= ctx->scriptArgCount) { - RValue* newScriptArgs = safeCalloc(writeIndex + 1, sizeof(RValue)); + RValue* newScriptArgs = (RValue *)safeCalloc(writeIndex + 1, sizeof(RValue)); if (ctx->scriptArgCount > 0) { memcpy(newScriptArgs, ctx->scriptArgs, ctx->scriptArgCount * sizeof(RValue)); free(ctx->scriptArgs); @@ -1476,7 +1476,7 @@ static void handleAddString(VMContext* ctx, RValue a, RValue b, uint8_t resultTy const char* sb = b.string != nullptr ? b.string : ""; size_t lenA = strlen(sa); size_t lenB = strlen(sb); - char* result = safeMalloc(lenA + lenB + 1); + char* result = (char *)safeMalloc(lenA + lenB + 1); memcpy(result, sa, lenA); memcpy(result + lenA, sb, lenB + 1); RValue_free(&a); @@ -1520,7 +1520,7 @@ static void handleMulString(VMContext* ctx, RValue a, RValue b, uint8_t resultTy RValue_free(&b); stackPushTyped(ctx, RValue_makeOwnedString(safeStrdup("")), resultType); } else { - char* result = safeMalloc(len * count + 1); + char* result = (char *)safeMalloc(len * count + 1); repeat(count, i) { memcpy(result + i * len, str, len); } @@ -1933,7 +1933,7 @@ static void handleCall(VMContext* ctx, uint32_t instr, const uint8_t* extraData) // Pop arguments from stack (args pushed right-to-left, so first arg is on top) RValue* args = nullptr; if (argCount > 0) { - args = safeCalloc(argCount, sizeof(RValue)); + args = (RValue *)safeCalloc(argCount, sizeof(RValue)); repeat(argCount, i) { args[i] = stackPop(ctx); } @@ -1949,7 +1949,7 @@ static void handleCall(VMContext* ctx, uint32_t instr, const uint8_t* extraData) char* display = RValue_toStringFancy(args[i]); if (i > 0) { - char* tmp = safeMalloc(strlen(functionArgumentList) + 2 + strlen(display) + 1); + char* tmp = (char *)safeMalloc(strlen(functionArgumentList) + 2 + strlen(display) + 1); sprintf(tmp, "%s, %s", functionArgumentList, display); free(functionArgumentList); functionArgumentList = tmp; @@ -2062,7 +2062,7 @@ static void handleCallV(VMContext* ctx, uint32_t instr) { RValue* args = nullptr; if (argCount > 0) { - args = safeCalloc(argCount, sizeof(RValue)); + args = (RValue *)safeCalloc(argCount, sizeof(RValue)); repeat(argCount, i) { args[i] = stackPop(ctx); } @@ -2195,7 +2195,7 @@ static void handlePushEnv(VMContext* ctx, uint32_t instr, uint32_t instrAddr) { } // Create env frame, save current context - EnvFrame* frame = safeMalloc(sizeof(EnvFrame)); + EnvFrame* frame = (EnvFrame *)safeMalloc(sizeof(EnvFrame)); frame->savedInstance = (Instance*) ctx->currentInstance; frame->savedOtherInstance = (Instance*) ctx->otherInstance; frame->instanceList = nullptr; @@ -3416,7 +3416,7 @@ VMContext* VM_create(DataWin* dataWin) { VMContext* ctx = (VMContext*) 0x70000000; memset(ctx, 0, sizeof(VMContext)); #else - VMContext* ctx = safeCalloc(1, sizeof(VMContext)); + VMContext* ctx = (VMContext *)safeCalloc(1, sizeof(VMContext)); #endif ctx->dataWin = dataWin; ctx->stack.top = 0; @@ -3477,8 +3477,8 @@ VMContext* VM_create(DataWin* dataWin) { // V17+ static initialization tracking if (dataWin->gen8.wadVersion >= 17) { - ctx->staticInitialized = safeCalloc(dataWin->code.count, sizeof(bool)); - ctx->staticStructs = safeCalloc(dataWin->code.count, sizeof(Instance*)); + ctx->staticInitialized = (bool *)safeCalloc(dataWin->code.count, sizeof(bool)); + ctx->staticStructs = (Instance **)safeCalloc(dataWin->code.count, sizeof(Instance*)); } else { ctx->staticInitialized = nullptr; ctx->staticStructs = nullptr; @@ -3554,7 +3554,7 @@ VMContext* VM_create(DataWin* dataWin) { // BC13/BC14 NEEDS the per-code map because BC<=14 has no CodeLocals chunk at all, so slots are allocated on first reference. ctx->codeLocalsSlotMaps = nullptr; if (dataWin->gen8.wadVersion >= 17 || 14 >= dataWin->gen8.wadVersion) { - ctx->codeLocalsSlotMaps = safeCalloc(dataWin->code.count, sizeof(*ctx->codeLocalsSlotMaps)); + ctx->codeLocalsSlotMaps = (IntIntHashMap *)safeCalloc(dataWin->code.count, sizeof(*ctx->codeLocalsSlotMaps)); } // Register built-in functions @@ -3563,7 +3563,7 @@ VMContext* VM_create(DataWin* dataWin) { // Pre-resolve all FUNC entries to cached builtin pointers or script code indices. // This eliminates per-call string hash lookups in handleCall. ctx->funcCallCacheCount = dataWin->func.functionCount; - ctx->funcCallCache = safeMalloc(dataWin->func.functionCount * sizeof(FuncCallCache)); + ctx->funcCallCache = (FuncCallCache *)safeMalloc(dataWin->func.functionCount * sizeof(FuncCallCache)); repeat(dataWin->func.functionCount, i) { const char* name = dataWin->func.functions[i].name; BuiltinFunc builtin = VM_findBuiltin(ctx, name); @@ -3624,8 +3624,8 @@ void VM_reset(VMContext* ctx) { if (ctx->dataWin->gen8.wadVersion >= 17) { free(ctx->staticInitialized); free(ctx->staticStructs); - ctx->staticInitialized = safeCalloc(ctx->dataWin->code.count, sizeof(bool)); - ctx->staticStructs = safeCalloc(ctx->dataWin->code.count, sizeof(Instance*)); + ctx->staticInitialized = (bool *)safeCalloc(ctx->dataWin->code.count, sizeof(bool)); + ctx->staticStructs = (Instance **)safeCalloc(ctx->dataWin->code.count, sizeof(Instance*)); } // Create the instance used for "self" in GLOB scripts @@ -3680,7 +3680,7 @@ RValue VM_executeCode(VMContext* ctx, int32_t codeIndex) { setCurrentCodeLocalsSlotMap(ctx); uint32_t localsCount = computeLocalsCount(ctx, code); - RValue* localVars = safeCalloc(localsCount, sizeof(RValue)); + RValue* localVars = (RValue *)safeCalloc(localsCount, sizeof(RValue)); ctx->localVars = localVars; ctx->localVarCount = localsCount; @@ -3752,7 +3752,7 @@ RValue VM_callCodeIndex(VMContext* ctx, int32_t codeIndex, RValue* args, int32_t setCurrentCodeLocalsSlotMap(ctx); uint32_t localsCount = computeLocalsCount(ctx, code); - RValue* localVars = safeCalloc(localsCount, sizeof(RValue)); + RValue* localVars = (RValue *)safeCalloc(localsCount, sizeof(RValue)); ctx->localVars = localVars; ctx->localVarCount = localsCount; @@ -3761,7 +3761,7 @@ RValue VM_callCodeIndex(VMContext* ctx, int32_t codeIndex, RValue* args, int32_t // the caller's original args remain valid and owner-tracked by the caller. RValue* scriptArgs = nullptr; if (argCount > 0 && args != nullptr) { - scriptArgs = safeCalloc(argCount, sizeof(RValue)); + scriptArgs = (RValue *)safeCalloc(argCount, sizeof(RValue)); repeat(argCount, argIdx) { RValue argCopy = RValue_makeIndependent(args[argIdx]); scriptArgs[argIdx] = argCopy; diff --git a/src/vm.h b/src/vm.h index a180c6072..2da4082ac 100644 --- a/src/vm.h +++ b/src/vm.h @@ -335,7 +335,7 @@ static inline const char* VM_getCallerName(VMContext* ctx) { static inline char* VM_createDedupKey(const char* callerName, const char* funcName) { // Build dedup key: "callerName\tfuncName" size_t keyLen = strlen(callerName) + 1 + strlen(funcName) + 1; - char* dedupKey = safeMalloc(keyLen); + char* dedupKey = (char *)safeMalloc(keyLen); snprintf(dedupKey, keyLen, "%s\t%s", callerName, funcName); return dedupKey; } @@ -369,13 +369,13 @@ static inline bool VM_shouldTraceVariable(StringBooleanEntry* traceMap, const ch if (shgeti(traceMap, varName) != -1) return true; // "obj_mainchara.hp" should trace EVERY variable read/write to the "hp" variable on the "obj_mainchara" object. size_t formattedSize = strlen(scopeName) + 1 + strlen(varName) + 1; - char *formatted = safeMalloc(formattedSize); + char *formatted = (char *)safeMalloc(formattedSize); snprintf(formatted, formattedSize, "%s.%s", scopeName, varName); if (shgeti(traceMap, formatted) != -1) return true; free(formatted); if (altScopeName != nullptr) { size_t altFormattedSize = strlen(altScopeName) + 1 + strlen(varName) + 1; - char *altFormatted = safeMalloc(altFormattedSize); + char *altFormatted = (char *)safeMalloc(altFormattedSize); snprintf(altFormatted, altFormattedSize, "%s.%s", altScopeName, varName); if (shgeti(traceMap, altFormatted) != -1) return true; free(altFormatted); diff --git a/src/vm_builtins.c b/src/vm_builtins.c index 0ecfb294b..a47ad1672 100644 --- a/src/vm_builtins.c +++ b/src/vm_builtins.c @@ -1244,7 +1244,7 @@ RValue VMBuiltins_getVariable(VMContext* ctx, Instance* inst, int16_t builtinVar } void VMBuiltins_setVariable(VMContext* ctx, Instance* inst, int16_t builtinVarId, const char* name, RValue val, int32_t arrayIndex) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: setVariable called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: setVariable called but no runner!"); requireNotNull(runner); // Structs: instance builtins are ordinary members. @@ -1762,7 +1762,7 @@ static RValue builtin_string_length(MAYBE_UNUSED VMContext* ctx, RValue* args, i // https://docs.vultr.com/clang/examples/remove-all-characters-in-a-string-except-alphabets void filterAlphabets(char *str) { - char *result = safeMalloc(strlen(str) + 1); + char *result = (char *)safeMalloc(strlen(str) + 1); int j = 0; for (int i = 0; str[i] != '\0'; i++) { if ((str[i] >= 'a' && str[i] <= 'z') || (str[i] >= 'A' && str[i] <= 'Z')) { @@ -2103,7 +2103,7 @@ static RValue builtin_string_copy(MAYBE_UNUSED VMContext* ctx, RValue* args, int if (byteEnd > strLen) byteEnd = strLen; int32_t nbytes = byteEnd - byteStart; - char* result = safeMalloc(nbytes + 1); + char* result = (char *)safeMalloc(nbytes + 1); memcpy(result, str + byteStart, (size_t) nbytes); result[nbytes] = '\0'; @@ -2132,7 +2132,7 @@ static RValue builtin_string_format(MAYBE_UNUSED VMContext* ctx, RValue* args, i int32_t numLen = (int32_t) strlen(numBuf); int32_t totalLen = leftPad + numLen; - char* result = safeMalloc(totalLen + 1); + char* result = (char *)safeMalloc(totalLen + 1); for (int32_t i = 0; leftPad > i; i++) result[i] = ' '; memcpy(result + leftPad, numBuf, (size_t) numLen); result[totalLen] = '\0'; @@ -2150,7 +2150,7 @@ static RValue builtin_string_repeat(MAYBE_UNUSED VMContext* ctx, RValue* args, i size_t strLen = strlen(str); size_t totalLen = strLen * (size_t) count; - char* result = safeMalloc(totalLen + 1); + char* result = (char *)safeMalloc(totalLen + 1); repeat(count, i) { memcpy(result + i * strLen, str, strLen); } @@ -2222,7 +2222,7 @@ static RValue builtin_string_pos(MAYBE_UNUSED VMContext* ctx, RValue* args, int3 // Appends a copy of [start, start + len) to the array as an owned string, growing it by one slot. static void appendSplitSegment(GMLArray* arr, int32_t* count, const char* start, int32_t len) { - char* segment = safeMalloc((size_t) len + 1); + char* segment = (char *)safeMalloc((size_t) len + 1); if (len > 0) memcpy(segment, start, (size_t) len); segment[len] = '\0'; GMLArray_growTo(arr, *count + 1); @@ -2301,7 +2301,7 @@ static RValue builtin_string_char_at(MAYBE_UNUSED VMContext* ctx, RValue* args, int32_t byteNext = byteStart; TextUtils_decodeUtf8(str, strLen, &byteNext); int32_t nbytes = byteNext - byteStart; - char* out = safeMalloc(nbytes + 1); + char* out = (char *)safeMalloc(nbytes + 1); memcpy(out, str + byteStart, (size_t) nbytes); out[nbytes] = '\0'; free(str); @@ -2345,7 +2345,7 @@ static RValue builtin_string_delete(MAYBE_UNUSED VMContext* ctx, RValue* args, i if (byteEnd > strLen) byteEnd = strLen; int32_t removeLen = byteEnd - byteStart; - char* result = safeMalloc(strLen - removeLen + 1); + char* result = (char *)safeMalloc(strLen - removeLen + 1); memcpy(result, str, (size_t) byteStart); memcpy(result + byteStart, str + byteEnd, (size_t) (strLen - byteEnd)); result[strLen - removeLen] = '\0'; @@ -2367,7 +2367,7 @@ static RValue builtin_string_insert(MAYBE_UNUSED VMContext* ctx, RValue* args, i int32_t bytePos = TextUtils_utf8AdvanceCodepoints(str, strLen, pos); if (bytePos > strLen) bytePos = strLen; - char* result = safeMalloc(strLen + subLen + 1); + char* result = (char *)safeMalloc(strLen + subLen + 1); memcpy(result, str, (size_t) bytePos); memcpy(result + bytePos, substr, (size_t) subLen); memcpy(result + bytePos + subLen, str + bytePos, (size_t) (strLen - bytePos)); @@ -2403,7 +2403,7 @@ static RValue builtin_string_replace(MAYBE_UNUSED VMContext* ctx, RValue* args, int32_t newLen = strLen - needleLen + replacementLen; int32_t before = (int32_t) (appearance - str); - char *outputString = safeMalloc(newLen + 1); + char *outputString = (char *)safeMalloc(newLen + 1); memcpy(outputString, str, before); memcpy(outputString + before, replacement, replacementLen); @@ -2436,7 +2436,7 @@ static RValue builtin_string_replace_all(MAYBE_UNUSED VMContext* ctx, RValue* ar int32_t strLen = (int32_t) strlen(str); int32_t resultLen = strLen + count * (replacementLen - needleLen); - char* result = safeMalloc(resultLen + 1); + char* result = (char *)safeMalloc(resultLen + 1); char* out = result; p = str; const char* match; @@ -3230,7 +3230,7 @@ static RValue builtin_room_get_info(VMContext* ctx, RValue* args, int32_t argCou } static RValue builtin_room_goto_next(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: room_goto_next called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: room_goto_next called but no runner!"); int32_t nextPos = runner->currentRoomOrderPosition + 1; if ((int32_t) runner->dataWin->gen8.roomOrderCount > nextPos) { @@ -3242,7 +3242,7 @@ static RValue builtin_room_goto_next(VMContext* ctx, MAYBE_UNUSED RValue* args, } static RValue builtin_room_goto_previous(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: room_goto_previous called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: room_goto_previous called but no runner!"); int32_t previousPos = runner->currentRoomOrderPosition - 1; if (previousPos >= 0) { @@ -3255,19 +3255,19 @@ static RValue builtin_room_goto_previous(VMContext* ctx, MAYBE_UNUSED RValue* ar static RValue builtin_room_goto(VMContext* ctx, RValue* args, int32_t argCount) { if (1 > argCount) return RValue_makeUndefined(); - Runner* runner = requireNotNullMessage(ctx->runner, "VM: room_goto called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: room_goto called but no runner!"); runner->pendingRoom = RValue_toInt32(args[0]); return RValue_makeUndefined(); } static RValue builtin_room_restart(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: room_restart called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: room_restart called but no runner!"); runner->pendingRoom = runner->currentRoomIndex; return RValue_makeUndefined(); } static RValue builtin_room_next(VMContext* ctx, RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: room_next called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: room_next called but no runner!"); int32_t roomId = RValue_toInt32(args[0]); DataWin* dw = runner->dataWin; repeat(dw->gen8.roomOrderCount, i) { @@ -3279,7 +3279,7 @@ static RValue builtin_room_next(VMContext* ctx, RValue* args, MAYBE_UNUSED int32 } static RValue builtin_room_previous(VMContext* ctx, RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: room_previous called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: room_previous called but no runner!"); int32_t roomId = RValue_toInt32(args[0]); DataWin* dw = runner->dataWin; repeat(dw->gen8.roomOrderCount, i) { @@ -3924,7 +3924,7 @@ static RValue builtin_struct_get_names(VMContext* ctx, RValue* args, int32_t arg char* name = VM_getVariableNameByVarId(ctx, entryOnTheVarStruct.key); // We don't need to worry about making it owned because the name is owned by the Runner itself - GMLArray_add(array, RValue_makeString(requireNotNullMessage(name, "Trying to set a variable that we do not know the name of! Bug?"))); + GMLArray_add(array, RValue_makeString((const char *)requireNotNullMessage(name, "Trying to set a variable that we do not know the name of! Bug?"))); } } } @@ -4535,7 +4535,7 @@ static RValue dsStreamReadValue(DsReadStream* s, int32_t version) { case DS_STREAM_VALUE_STRING: { int32_t len = dsStreamReadS32(s); if (s->error || 0 > len || s->pos + len > s->size) { s->error = true; return RValue_makeUndefined(); } - char* str = safeMalloc((size_t) len + 1); + char* str = (char *)safeMalloc((size_t) len + 1); if (len > 0) memcpy(str, s->data + s->pos, (size_t) len); str[len] = '\0'; s->pos += len; @@ -4599,7 +4599,7 @@ static RValue builtin_ds_list_read(VMContext* ctx, RValue* args, MAYBE_UNUSED in if (2 > hexLen || (hexLen & 1) != 0) return RValue_makeBool(false); int32_t byteLen = hexLen / 2; - uint8_t* bytes = safeMalloc((size_t) byteLen); + uint8_t* bytes = (uint8_t *)safeMalloc((size_t) byteLen); repeat(byteLen, i) { int hi = dsHexNibble(hex[i * 2]); int lo = dsHexNibble(hex[i * 2 + 1]); @@ -4725,7 +4725,7 @@ static void dsStreamAppendValues(uint8_t** buf, const RValue* items, int32_t len // Consumes "buf" (stb_ds array): hex-encodes it, frees it, and returns the hex as an owned-string RValue. static RValue dsStreamFinishToHexString(uint8_t* buf) { int32_t byteLen = (int32_t) arrlen(buf); - char* hex = safeMalloc((size_t) byteLen * 2 + 1); + char* hex = (char *)safeMalloc((size_t) byteLen * 2 + 1); static const char HEX_CHARS[] = "0123456789ABCDEF"; repeat(byteLen, i) { hex[i * 2] = HEX_CHARS[(buf[i] >> 4) & 0xF]; @@ -4788,7 +4788,7 @@ static RValue builtin_ds_grid_create(VMContext* ctx, MAYBE_UNUSED RValue* args, runner->dsGridPool[i].freed = false; runner->dsGridPool[i].width = width; runner->dsGridPool[i].height = height; - runner->dsGridPool[i].items = count > 0 ? safeCalloc(count, sizeof(RValue)) : nullptr; + runner->dsGridPool[i].items = count > 0 ? (RValue *)safeCalloc(count, sizeof(RValue)) : nullptr; return RValue_makeReal(i); } } @@ -4796,7 +4796,7 @@ static RValue builtin_ds_grid_create(VMContext* ctx, MAYBE_UNUSED RValue* args, DsGrid newGrid = {0}; newGrid.width = width; newGrid.height = height; - newGrid.items = count > 0 ? safeCalloc(count, sizeof(RValue)) : nullptr; + newGrid.items = count > 0 ? (RValue *)safeCalloc(count, sizeof(RValue)) : nullptr; int32_t id = poolSize; arrput(runner->dsGridPool, newGrid); return RValue_makeReal(id); @@ -4881,11 +4881,11 @@ static RValue builtin_ds_grid_add(VMContext* ctx, MAYBE_UNUSED RValue* args, MAY RValue* slot = &grid->items[x + (y * grid->width)]; if (slot->type == RVALUE_STRING && args[3].type == RVALUE_STRING) { // If they are both strings, then we concatenate them - const char* sa = requireNotNull(slot->string); - const char* sb = requireNotNull(args[3].string); + const char* sa = (const char *)requireNotNull(slot->string); + const char* sb = (const char *)requireNotNull(args[3].string); size_t lenA = strlen(sa); size_t lenB = strlen(sb); - char* result = safeMalloc(lenA + lenB + 1); + char* result = (char *)safeMalloc(lenA + lenB + 1); memcpy(result, sa, lenA); memcpy(result + lenA, sb, lenB + 1); RValue_free(slot); @@ -4910,7 +4910,7 @@ static RValue builtin_ds_grid_resize(VMContext* ctx, MAYBE_UNUSED RValue* args, if (0 > height) height = 0; size_t count = (size_t) width * (size_t) height; - RValue* newGrid = count > 0 ? safeCalloc(count, sizeof(RValue)) : nullptr; + RValue* newGrid = count > 0 ? (RValue *)safeCalloc(count, sizeof(RValue)) : nullptr; int32_t copyWidth = width > grid->width ? grid->width : width; int32_t copyHeight = height > grid->height ? grid->height : height; @@ -5058,7 +5058,7 @@ static RValue builtin_ds_stack_read(VMContext* ctx, RValue* args, MAYBE_UNUSED i if (2 > hexLen || (hexLen & 1) != 0) return RValue_makeBool(false); int32_t byteLen = hexLen / 2; - uint8_t* bytes = safeMalloc((size_t) byteLen); + uint8_t* bytes = (uint8_t *)safeMalloc((size_t) byteLen); repeat(byteLen, i) { int hi = dsHexNibble(hex[i * 2]); int lo = dsHexNibble(hex[i * 2 + 1]); @@ -5236,7 +5236,7 @@ static RValue builtin_ds_queue_read(VMContext* ctx, RValue* args, MAYBE_UNUSED i if (2 > hexLen || (hexLen & 1) != 0) return RValue_makeBool(false); int32_t byteLen = hexLen / 2; - uint8_t* bytes = safeMalloc((size_t) byteLen); + uint8_t* bytes = (uint8_t *)safeMalloc((size_t) byteLen); repeat(byteLen, i) { int hi = dsHexNibble(hex[i * 2]); int lo = dsHexNibble(hex[i * 2 + 1]); @@ -6991,7 +6991,7 @@ static RValue builtin_file_text_read_string(VMContext* ctx, RValue* args, int32_ } int32_t len = file->readPos - start; - char* result = safeMalloc((size_t) len + 1); + char* result = (char *)safeMalloc((size_t) len + 1); memcpy(result, file->content + start, (size_t) len); result[len] = '\0'; return RValue_makeOwnedString(result); @@ -7026,7 +7026,7 @@ static RValue builtin_file_text_readln(VMContext* ctx, RValue* args, int32_t arg } // Now we copy it because we already know the size of the string! - char* string = safeMalloc(size + 1); // +1 because the last one is null + char* string = (char *)safeMalloc(size + 1); // +1 because the last one is null memcpy(string, file->content + file->readPos, size); string[size] = '\0'; file->readPos = readPos; @@ -7064,7 +7064,7 @@ static RValue builtin_file_text_write_string(VMContext* ctx, RValue* args, int32 char* str = RValue_toString(args[1]); size_t oldLen = strlen(file->writeBuffer); size_t addLen = strlen(str); - file->writeBuffer = safeRealloc(file->writeBuffer, oldLen + addLen + 1); + file->writeBuffer = (char *)safeRealloc(file->writeBuffer, oldLen + addLen + 1); memcpy(file->writeBuffer + oldLen, str, addLen); file->writeBuffer[oldLen + addLen] = '\0'; free(str); @@ -7082,7 +7082,7 @@ static RValue builtin_file_text_writeln(VMContext* ctx, RValue* args, int32_t ar if (!file->isWriteMode) return RValue_makeUndefined(); size_t oldLen = strlen(file->writeBuffer); - file->writeBuffer = safeRealloc(file->writeBuffer, oldLen + 2); + file->writeBuffer = (char *)safeRealloc(file->writeBuffer, oldLen + 2); file->writeBuffer[oldLen] = '\n'; file->writeBuffer[oldLen + 1] = '\0'; @@ -7101,7 +7101,7 @@ static RValue builtin_file_text_write_real(VMContext* ctx, RValue* args, int32_t char* str = RValue_toString(args[1]); size_t oldLen = strlen(file->writeBuffer); size_t addLen = strlen(str); - file->writeBuffer = safeRealloc(file->writeBuffer, oldLen + addLen + 1); + file->writeBuffer = (char *)safeRealloc(file->writeBuffer, oldLen + addLen + 1); memcpy(file->writeBuffer + oldLen, str, addLen); file->writeBuffer[oldLen + addLen] = '\0'; free(str); @@ -7844,7 +7844,7 @@ static RValue builtin_instance_create_layer(VMContext* ctx, RValue* args, int32_ variableInstanceSetOn( ctx, inst, - requireNotNullMessage(name, "Trying to set a variable that we do not know the name of! Bug?"), + (const char *)requireNotNullMessage(name, "Trying to set a variable that we do not know the name of! Bug?"), target, "instance_create_layer" ); @@ -8505,7 +8505,7 @@ static RValue builtin_action_set_vspeed(VMContext* ctx, MAYBE_UNUSED RValue* arg static int32_t gmlBufferCreate(Runner* runner, int32_t size, int32_t type, int32_t alignment) { GmlBuffer buf = {0}; buf.size = size > 0 ? size : 1; - buf.data = safeCalloc((size_t) buf.size, 1); + buf.data = (uint8_t *)safeCalloc((size_t) buf.size, 1); buf.position = 0; buf.usedSize = (type == GML_BUFFER_GROW) ? 0 : buf.size; buf.alignment = alignment > 0 ? alignment : 1; @@ -8535,7 +8535,7 @@ static void gmlBufferEnsureSize(GmlBuffer* buf, int32_t newSize) { // Double or use newSize, whichever is larger int32_t newAlloc = buf->size * 2; if (newAlloc < newSize) newAlloc = newSize; - buf->data = safeRealloc(buf->data, (size_t) newAlloc); + buf->data = (uint8_t *)safeRealloc(buf->data, (size_t) newAlloc); memset(buf->data + buf->size, 0, (size_t) (newAlloc - buf->size)); buf->size = newAlloc; } @@ -8746,7 +8746,7 @@ static RValue builtin_buffer_read(MAYBE_UNUSED VMContext* ctx, RValue* args, MAY buf->position++; } int32_t len = buf->position - start; - char* str = safeMalloc((size_t) len + 1); + char* str = (char *)safeMalloc((size_t) len + 1); memcpy(str, buf->data + start, (size_t) len); str[len] = '\0'; // Skip past the null terminator @@ -8759,7 +8759,7 @@ static RValue builtin_buffer_read(MAYBE_UNUSED VMContext* ctx, RValue* args, MAY int32_t start = buf->position; int32_t len = buf->size - start; if (0 > len) len = 0; - char* str = safeMalloc((size_t) len + 1); + char* str = (char *)safeMalloc((size_t) len + 1); if (len > 0) memcpy(str, buf->data + start, (size_t) len); str[len] = '\0'; buf->position = buf->size; @@ -8894,7 +8894,7 @@ static RValue builtin_buffer_save_ext(MAYBE_UNUSED VMContext* ctx, RValue* args, static char* gmlAsyncBufferResolvePath(const char* groupName, const char* filename) { if (groupName == nullptr || groupName[0] == '\0') return safeStrdup(filename); size_t length = strlen(groupName) + 1 + strlen(filename) + 1; - char* path = safeMalloc(length); + char* path = (char *)safeMalloc(length); snprintf(path, length, "%s/%s", groupName, filename); return path; } @@ -9034,7 +9034,7 @@ static RValue builtin_filename_change_ext(MAYBE_UNUSED VMContext* ctx, MAYBE_UNU if (last != nullptr && last != 0) { long index = last - fname; - char* new_name = safeMalloc(index + strlen(newext) + 1); + char* new_name = (char *)safeMalloc(index + strlen(newext) + 1); memcpy(new_name, fname, (size_t) index); memcpy(new_name + index, newext, (size_t) strlen(newext)); new_name[index + strlen(newext)] = '\0'; @@ -9073,7 +9073,7 @@ static RValue builtin_buffer_base64_encode(MAYBE_UNUSED VMContext* ctx, RValue* size = (size_t)(maxBoundary - offset); } - char* out = safeMalloc(BASE64_ENCODE_OUT_SIZE(size)); + char* out = (char *)safeMalloc(BASE64_ENCODE_OUT_SIZE(size)); base64_encode((const unsigned char*) buf->data + offset, size, out); return RValue_makeOwnedString(out); } @@ -9084,7 +9084,7 @@ static RValue builtin_buffer_base64_decode(MAYBE_UNUSED VMContext* ctx, RValue* char* input = RValue_toString(args[1]); unsigned int inLen = (unsigned int) strlen(input); size_t outLen = BASE64_DECODE_OUT_SIZE(inLen); - uint8_t* out = safeMalloc(outLen); + uint8_t* out = (uint8_t *)safeMalloc(outLen); base64_decode(input, inLen, out); free(input); int32_t id = gmlBufferCreate(runner, outLen, GML_BUFFER_GROW, 1); @@ -9100,7 +9100,7 @@ static RValue builtin_base64_encode(MAYBE_UNUSED VMContext* ctx, RValue* args, M if (1 > argCount) return RValue_makeOwnedString(safeStrdup("")); char* input = RValue_toString(args[0]); unsigned int inLen = (unsigned int) strlen(input); - char* out = safeMalloc(BASE64_ENCODE_OUT_SIZE(inLen)); + char* out = (char *)safeMalloc(BASE64_ENCODE_OUT_SIZE(inLen)); base64_encode((const unsigned char*) input, inLen, out); free(input); return RValue_makeOwnedString(out); @@ -9111,7 +9111,7 @@ static RValue builtin_base64_decode(MAYBE_UNUSED VMContext* ctx, RValue* args, M char* input = RValue_toString(args[0]); unsigned int inLen = (unsigned int) strlen(input); unsigned int outCap = BASE64_DECODE_OUT_SIZE(inLen); - unsigned char* out = safeMalloc(outCap + 1); + unsigned char* out = (unsigned char *)safeMalloc(outCap + 1); unsigned int outLen = base64_decode(input, inLen, out); out[outLen] = '\0'; free(input); @@ -9121,7 +9121,7 @@ static RValue builtin_base64_decode(MAYBE_UNUSED VMContext* ctx, RValue* args, M // Converts the "digest" to a hex string static char* convertToHexString(unsigned char* digest, int32_t digestLength) { int32_t stringLength = digestLength * 2; - char* hex = safeMalloc(stringLength + 1); + char* hex = (char *)safeMalloc(stringLength + 1); for (int32_t i = 0; digestLength > i; i++) { sprintf(&hex[i * 2], "%02x", digest[i]); } @@ -12047,21 +12047,21 @@ static RValue builtin_action_message(MAYBE_UNUSED VMContext* ctx, RValue* args, // action_another_room(room_id) - jumps to the given room. static RValue builtin_action_another_room(VMContext* ctx, RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: action_another_room called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: action_another_room called but no runner!"); runner->pendingRoom = RValue_toInt32(args[0]); return RValue_makeUndefined(); } // action_current_room() - restarts the current room. static RValue builtin_action_current_room(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: action_current_room called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: action_current_room called but no runner!"); runner->pendingRoom = runner->currentRoomIndex; return RValue_makeUndefined(); } // action_next_room() - goes to the next room in the room order. static RValue builtin_action_next_room(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_UNUSED int32_t argCount) { - Runner* runner = requireNotNullMessage(ctx->runner, "VM: action_next_room called but no runner!"); + Runner* runner = (Runner *)requireNotNullMessage(ctx->runner, "VM: action_next_room called but no runner!"); int32_t nextPos = runner->currentRoomOrderPosition + 1; if ((int32_t) runner->dataWin->gen8.roomOrderCount > nextPos) { runner->pendingRoom = runner->dataWin->gen8.roomOrder[nextPos]; @@ -12217,7 +12217,7 @@ static RValue builtin_tile_add(VMContext* ctx, RValue* args, MAYBE_UNUSED int32_ uint32_t newId = runner->nextInstanceId++; uint32_t newCount = room->tileCount + 1; - room->tiles = safeRealloc(room->tiles, newCount * sizeof(RoomTile)); + room->tiles = (RoomTile *)safeRealloc(room->tiles, newCount * sizeof(RoomTile)); RoomTile* tile = &room->tiles[room->tileCount]; tile->x = RValue_toInt32(args[5]); tile->y = RValue_toInt32(args[6]); @@ -12617,7 +12617,7 @@ static RValue builtin_layer_create(VMContext* ctx, RValue* args, int32_t argCoun name = RValue_toString(args[1]); } else { // Technically could be smaller, but let's be safe - char* generatedName = safeMalloc(16); + char* generatedName = (char *)safeMalloc(16); snprintf(generatedName, 16, "_layer_%x", id); name = generatedName; } @@ -12661,7 +12661,7 @@ static RValue builtin_layer_background_create(VMContext* ctx, RValue* args, MAYB if (runtimeLayer == nullptr) return RValue_makeReal(-1.0); - RuntimeBackgroundElement* bg = safeMalloc(sizeof(RuntimeBackgroundElement)); + RuntimeBackgroundElement* bg = (RuntimeBackgroundElement *)safeMalloc(sizeof(RuntimeBackgroundElement)); bg->spriteIndex = spriteIndex; bg->visible = true; bg->hTiled = false; @@ -13446,7 +13446,7 @@ static RValue builtin_array_create(VMContext* ctx, RValue* args, int32_t argCoun // @@This@@ - GMS2 internal function returning the current instance's ID. // Emitted by the GMS2 compiler for expressions like `self` when used as a value. static RValue builtin_This(VMContext* ctx, MAYBE_UNUSED RValue* args, MAYBE_UNUSED int32_t argCount) { - Instance* instance = requireNotNullMessage(ctx->currentInstance, "Called @@This@@ while there isn't a current instance on the context!"); + Instance* instance = (Instance *)requireNotNullMessage(ctx->currentInstance, "Called @@This@@ while there isn't a current instance on the context!"); return RValue_makeInt32((int32_t) instance->instanceId); } @@ -14801,7 +14801,7 @@ static RValue fontAddSpriteImpl(VMContext* ctx, int32_t spriteIndex, uint16_t* c // Allocate glyphs (+ 1 for synthetic space if needed) uint32_t totalGlyphs = hasSpace ? glyphCount : glyphCount + 1; - FontGlyph* glyphs = safeMalloc(totalGlyphs * sizeof(FontGlyph)); + FontGlyph* glyphs = (FontGlyph *)safeMalloc(totalGlyphs * sizeof(FontGlyph)); repeat(glyphCount, i) { int32_t tpagIdx = sprite->tpagIndices[i]; @@ -14851,7 +14851,7 @@ static RValue fontAddSpriteImpl(VMContext* ctx, int32_t spriteIndex, uint16_t* c // Grow the font array and create the new font uint32_t newFontIndex = dw->font.count; dw->font.count++; - dw->font.fonts = safeRealloc(dw->font.fonts, dw->font.count * sizeof(Font)); + dw->font.fonts = (Font *)safeRealloc(dw->font.fonts, dw->font.count * sizeof(Font)); Font* font = &dw->font.fonts[newFontIndex]; font->name = "sprite_font"; @@ -15208,7 +15208,7 @@ static RValue builtin_shader_set_uniform_f_array(VMContext* ctx, MAYBE_UNUSED RV uint32_t count = GMLArray_length1D(arr); if (count == 0) return RValue_makeUndefined(); - float* values = safeMalloc(count * sizeof(float)); + float* values = (float *)safeMalloc(count * sizeof(float)); for (uint32_t i = 0; i < count; i++) { values[i] = (float) RValue_toReal(*GMLArray_slot(arr, i)); } From 28d042becfd81fe8aac5ce612ff8bbeb53ee46eb Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 15:43:33 -0400 Subject: [PATCH 19/21] headers --- src/desktop/backends/sdl1.c | 3 +-- src/desktop/backends/sdl2.c | 3 +-- src/desktop/backends/sdl3.c | 5 +---- 3 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/desktop/backends/sdl1.c b/src/desktop/backends/sdl1.c index 30b04b546..da2020d5b 100644 --- a/src/desktop/backends/sdl1.c +++ b/src/desktop/backends/sdl1.c @@ -1,9 +1,8 @@ +#include #include #include -#include #include -#include #include "common.h" #include "input_recording.h" diff --git a/src/desktop/backends/sdl2.c b/src/desktop/backends/sdl2.c index 91029a636..753d4eadf 100644 --- a/src/desktop/backends/sdl2.c +++ b/src/desktop/backends/sdl2.c @@ -1,8 +1,7 @@ +#include #include -#include #include -#include #include "common.h" #include "input_recording.h" diff --git a/src/desktop/backends/sdl3.c b/src/desktop/backends/sdl3.c index eea805e25..28ccaacb7 100644 --- a/src/desktop/backends/sdl3.c +++ b/src/desktop/backends/sdl3.c @@ -1,10 +1,7 @@ -#include +#include #include -#include #include -#include -#include #include "common.h" #include "input_recording.h" From d66f46286c066d66e5f9106b46406057bd6ba1cf Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Fri, 19 Jun 2026 16:14:58 -0400 Subject: [PATCH 20/21] more explicit casts --- src/vm_builtins.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vm_builtins.c b/src/vm_builtins.c index a47ad1672..abdc31f09 100644 --- a/src/vm_builtins.c +++ b/src/vm_builtins.c @@ -13594,7 +13594,7 @@ static RValue builtin_finish_catch(MAYBE_UNUSED VMContext* ctx, MAYBE_UNUSED RVa // @@throw@@ - throws a custom exception static RValue builtin_throw(VMContext* ctx, RValue* args, int32_t argCount) { char* message = RValue_toString(args[0]); - VMException* exception = safeCalloc(1, sizeof(VMException)); + VMException* exception = (VMException *)safeCalloc(1, sizeof(VMException)); exception->message = message; ctx->exception = exception; return RValue_makeUndefined(); From 892db2fc150c732143d5981e7cfd30ca987b1567 Mon Sep 17 00:00:00 2001 From: Un1q32 Date: Sat, 20 Jun 2026 10:49:50 -0400 Subject: [PATCH 21/21] more explicit casts --- src/desktop/main.c | 2 +- src/vm.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/desktop/main.c b/src/desktop/main.c index 304295e88..860e588dd 100644 --- a/src/desktop/main.c +++ b/src/desktop/main.c @@ -890,7 +890,7 @@ char* collapseNewlines(const char *input) { } size_t len = strlen(input); - char *result = malloc(len + 1); + char *result = (char *)malloc(len + 1); if (result == nullptr) { return nullptr; } diff --git a/src/vm.c b/src/vm.c index 599ace8df..0410d6605 100644 --- a/src/vm.c +++ b/src/vm.c @@ -2123,7 +2123,7 @@ static void handleCallV(VMContext* ctx, uint32_t instr) { } else { fprintf(stderr, "VM: [%s] CALLV with unresolvable function reference (type=%d, codeIndex=%d)\n", ctx->currentCodeName, function.type, codeIndex); #ifdef ENABLE_WAD17 - VMException* exception = safeCalloc(1, sizeof(VMException)); + VMException* exception = (VMException *)safeCalloc(1, sizeof(VMException)); exception->message = safeStrdup("CALLV with unresolvable function reference"); ctx->exception = exception; result = RValue_makeUndefined();