From 38d024c6f3d55f1ffbb1597c563ad0ee1625b09f Mon Sep 17 00:00:00 2001 From: Steven Le Rouzic Date: Sun, 29 Dec 2024 23:38:15 +0100 Subject: Fix use of aligned_alloc on Linux --- asl/tests/format_tests.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'asl/tests/format_tests.cpp') diff --git a/asl/tests/format_tests.cpp b/asl/tests/format_tests.cpp index 906fce6..042fcb4 100644 --- a/asl/tests/format_tests.cpp +++ b/asl/tests/format_tests.cpp @@ -12,6 +12,11 @@ class StringSink : public asl::Writer char* m_data{}; public: + ~StringSink() + { + reset(); + } + void write(asl::span str) override { m_data = reinterpret_cast(asl::GlobalHeap::realloc( @@ -28,9 +33,12 @@ public: void reset() { - m_current_len = 0; - asl::GlobalHeap::dealloc(m_data, asl::layout::array(m_current_len)); - m_data = nullptr; + if (m_data != nullptr) + { + m_current_len = 0; + asl::GlobalHeap::dealloc(m_data, asl::layout::array(m_current_len)); + m_data = nullptr; + } } }; -- cgit