Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created November 20, 2021 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/6065dd236bff98c7741f8e820f16249f to your computer and use it in GitHub Desktop.
Save MasterDuke17/6065dd236bff98c7741f8e820f16249f to your computer and use it in GitHub Desktop.
diff --git src/core/fixedsizealloc.c src/core/fixedsizealloc.c
index d0b568de3..2c7750f36 100644
--- src/core/fixedsizealloc.c
+++ src/core/fixedsizealloc.c
@@ -10,7 +10,7 @@
* behavior. */
/* Turn this on to switch to a mode where we debug by size. */
-#define FSA_SIZE_DEBUG 0
+#define FSA_SIZE_DEBUG 1
#if FSA_SIZE_DEBUG
typedef struct {
size_t alloc_size;
@@ -246,10 +246,10 @@ void * MVM_fixed_size_realloc(MVMThreadContext *tc, MVMFixedSizeAlloc *al, void
/* Reallocs a piece of memory to the specified size, using the FSA. */
void * MVM_fixed_size_realloc_at_safepoint(MVMThreadContext *tc, MVMFixedSizeAlloc *al, void * p, size_t old_bytes, size_t new_bytes) {
#if FSA_SIZE_DEBUG
- MVMFixedSizeAllocDebug *new_p = MVM_fixed_size_alloc(tc, al, new_bytes);
- memcpy(new_p, (char *)p, new_bytes > old_bytes ? old_bytes : new_bytes);
+ MVMFixedSizeAllocDebug *new_p = (MVMFixedSizeAllocDebug *)((char *)MVM_fixed_size_alloc(tc, al, new_bytes) - 8);
+ memcpy(new_p->memory, (char *)p, new_bytes > old_bytes ? old_bytes : new_bytes);
MVM_fixed_size_free_at_safepoint(tc, al, old_bytes, p);
- return new_p;
+ return &(new_p->memory);
#else
MVMuint32 old_bin = bin_for(old_bytes);
MVMuint32 new_bin = bin_for(new_bytes);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment