From 9cd83fc4267e241dccc29f5134063c1c61f5085f Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Thu, 11 Sep 2025 13:18:19 -0400 Subject: [PATCH] Call ~ControlBlock It's trivially destructible, but just in case. Compiler should optimize it out --- src/reference.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/reference.hpp b/src/reference.hpp index a12a223..e9bedb7 100644 --- a/src/reference.hpp +++ b/src/reference.hpp @@ -182,8 +182,9 @@ private: // Release the bias - decrement weak count for strong references uint32_t prev_weak = control_block->decrement_weak(); - // If weak count hits 0, free control block + // If weak count hits 0, destroy and free control block if (prev_weak == 1) { + control_block->~ControlBlock(); std::free(control_block); } } @@ -329,8 +330,9 @@ private: if (control_block) { uint32_t prev_weak = control_block->decrement_weak(); - // If weak count hits 0, free control block + // If weak count hits 0, destroy and free control block if (prev_weak == 1) { + control_block->~ControlBlock(); std::free(control_block); } }