From 1a78a9ab5fb690a158087175ce886a9e760e49b5 Mon Sep 17 00:00:00 2001 From: CPunch Date: Fri, 25 Aug 2023 21:22:10 -0500 Subject: [PATCH] finally fixed this memory bug we were accidentally tracking frees of stuff that was never allocated lol --- src/cmem.c | 1 + src/cstate.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cmem.c b/src/cmem.c index d3427d4..e8c9e55 100644 --- a/src/cmem.c +++ b/src/cmem.c @@ -10,6 +10,7 @@ // realloc wrapper void *cosmoM_reallocate(CState *state, void *buf, size_t oldSize, size_t newSize) { + if (buf == NULL) oldSize = 0; #ifdef GC_DEBUG printf("old allocated bytes: %ld\n", state->allocatedBytes); if (buf) { diff --git a/src/cstate.c b/src/cstate.c index fbe704e..6b241b8 100644 --- a/src/cstate.c +++ b/src/cstate.c @@ -106,7 +106,6 @@ void cosmoV_freeState(CState *state) // free our gray stack & finally free the state structure cosmoM_freearray(state, CObj *, state->grayStack.array, state->grayStack.capacity); - // TODO: yeah idk, it looks like im missing 688 bytes somewhere? i'll look into it later #ifdef GC_DEBUG if (state->allocatedBytes != 0) { printf("state->allocatedBytes doesn't match, got %lu\n", state->allocatedBytes);