diff --git a/src/TracingHeap/TracingHeap.c b/src/TracingHeap/TracingHeap.c index bab34e4..a81e286 100644 --- a/src/TracingHeap/TracingHeap.c +++ b/src/TracingHeap/TracingHeap.c @@ -29,8 +29,8 @@ int TracingHeap_Create(TracingHeap* self, allocator_t* allocator) static void _TracingHeap_ForceDestroyObject(TracingHeap* self, TracingObject* object) { - self->config.destructor(self->config.destructor_context, object->data); size_t allocated_size = self->config.size_query(self->config.size_query_context, object->data); + self->config.destructor(self->config.destructor_context, object->data); Allocator_Free(self->allocator, object, allocated_size); } @@ -166,13 +166,13 @@ size_t TracingHeap_TraceNextN(TracingHeap* self, size_t n) static int _TracingHeap_DestroyObject(TracingHeap* self, TracingObject* unreachable_object) { + size_t allocated_size = self->config.size_query(self->config.size_query_context, unreachable_object->data); + int destructor_code = self->config.destructor(self->config.destructor_context, unreachable_object->data); if (destructor_code) { return destructor_code; } - size_t allocated_size = self->config.size_query(self->config.size_query_context, unreachable_object->data); - Allocator_Free(self->allocator, unreachable_object, allocated_size); return EXIT_SUCCESS;