Skip to content

Commit

Permalink
Fix: run finalizer when an object is manually freed.
Browse files Browse the repository at this point in the history
Only applies to large objects, since small objects are never freed
manually (NOOP).

This shouldn't happen since references aren't expected to be freed
manually, but still implemented to bugs further down the line.
  • Loading branch information
ysbaddaden committed Jan 24, 2018
1 parent 4b823c5 commit bed169a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/global_allocator.c
Expand Up @@ -247,6 +247,10 @@ void GC_GlobalAllocator_deallocateLarge(GlobalAllocator *self, void *pointer) {
Chunk *chunk = (Chunk *)pointer - 1;
chunk->allocated = (uint8_t)0;

if (Object_hasFinalizer(&chunk->object)) {
Object_runThenClearFinalizer(&chunk->object);
}

// TODO: merge with next free chunks (?)
}

Expand Down

0 comments on commit bed169a

Please sign in to comment.