From c6ff6ad31d36a1970ad8c22887031b0ba7cfeca9 Mon Sep 17 00:00:00 2001 From: VegOwOtenks Date: Wed, 16 Oct 2024 17:18:14 +0200 Subject: [PATCH] Changed size_query and destructor call order --- src/TracingHeap/TracingHeap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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;