From bfdbfd376a0c0e2637e5af9a1d3a13d1485f4fa7 Mon Sep 17 00:00:00 2001 From: elasota <1137273+elasota@users.noreply.github.com> Date: Sat, 7 Sep 2024 15:39:52 -0400 Subject: [PATCH] Allow custom stack allocator to have non-static Free function --- include/rapidjson/internal/stack.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/rapidjson/internal/stack.h b/include/rapidjson/internal/stack.h index 73abd706e9..3c0f1d00eb 100644 --- a/include/rapidjson/internal/stack.h +++ b/include/rapidjson/internal/stack.h @@ -101,7 +101,7 @@ class Stack { void ShrinkToFit() { if (Empty()) { // If the stack is empty, completely deallocate the memory. - Allocator::Free(stack_); // NOLINT (+clang-analyzer-unix.Malloc) + allocator_->Free(stack_); // NOLINT (+clang-analyzer-unix.Malloc) stack_ = 0; stackTop_ = 0; stackEnd_ = 0; @@ -206,7 +206,8 @@ class Stack { } void Destroy() { - Allocator::Free(stack_); + if (allocator_) + allocator_->Free(stack_); RAPIDJSON_DELETE(ownAllocator_); // Only delete if it is owned by the stack }