From 60c4de2827229d515794b1c1f84524fed03b3c3f Mon Sep 17 00:00:00 2001 From: jatin Date: Mon, 17 Jun 2024 22:07:55 -0700 Subject: [PATCH] More CI fixes --- .../Allocators/chowdsp_STLArenaAllocator.h | 2 +- .../Structures/chowdsp_AbstractTree.cpp | 7 ++++--- .../chowdsp_data_structures/Structures/chowdsp_EnumMap.h | 2 +- .../chowdsp_data_structures_test/AbstractTreeTest.cpp | 3 --- .../chowdsp_data_structures_test/EnumMapTest.cpp | 2 -- .../chowdsp_data_structures_test/STLArenaAllocatorTest.cpp | 4 ---- 6 files changed, 6 insertions(+), 14 deletions(-) diff --git a/modules/common/chowdsp_data_structures/Allocators/chowdsp_STLArenaAllocator.h b/modules/common/chowdsp_data_structures/Allocators/chowdsp_STLArenaAllocator.h index b41cef897..df0e705f7 100644 --- a/modules/common/chowdsp_data_structures/Allocators/chowdsp_STLArenaAllocator.h +++ b/modules/common/chowdsp_data_structures/Allocators/chowdsp_STLArenaAllocator.h @@ -28,7 +28,7 @@ struct STLArenaAllocator T* allocate (std::size_t n) { - return static_cast (arena.allocate_bytes (n, alignof (T))); + return static_cast (arena.allocate_bytes (n * sizeof (T), alignof (T))); } void deallocate (T*, std::size_t) const diff --git a/modules/common/chowdsp_data_structures/Structures/chowdsp_AbstractTree.cpp b/modules/common/chowdsp_data_structures/Structures/chowdsp_AbstractTree.cpp index dcd95bf0a..3b49285ee 100644 --- a/modules/common/chowdsp_data_structures/Structures/chowdsp_AbstractTree.cpp +++ b/modules/common/chowdsp_data_structures/Structures/chowdsp_AbstractTree.cpp @@ -10,7 +10,7 @@ template AbstractTree::~AbstractTree() { doForAllNodes ([] (Node& node) - { node.~Node(); }); + { node.leaf.reset(); }); } template @@ -108,7 +108,7 @@ void AbstractTree::removeNode (Node& node) node.parent->last_child = node.prev_sibling; } - node.~Node(); + node.leaf.reset(); } template @@ -150,9 +150,10 @@ template void AbstractTree::clear() { doForAllNodes ([] (Node& node) - { node.~Node(); }); + { node.leaf.reset(); }); allocator.reset (64 * sizeof (Node)); count = 0; + root_node = {}; } template diff --git a/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h b/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h index 3095b583e..cd0c21906 100644 --- a/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h +++ b/modules/common/chowdsp_data_structures/Structures/chowdsp_EnumMap.h @@ -126,7 +126,7 @@ struct EnumMap { ++index; ++iter; - } while (! iter->has_value() && index < std::tuple_size_v); + } while (index < std::tuple_size_v && ! iter->has_value()); if (index < std::tuple_size_v) key = magic_enum::enum_value (index); diff --git a/tests/common_tests/chowdsp_data_structures_test/AbstractTreeTest.cpp b/tests/common_tests/chowdsp_data_structures_test/AbstractTreeTest.cpp index b35bc736c..d52487f0c 100644 --- a/tests/common_tests/chowdsp_data_structures_test/AbstractTreeTest.cpp +++ b/tests/common_tests/chowdsp_data_structures_test/AbstractTreeTest.cpp @@ -1,8 +1,6 @@ #include #include -#if ! JUCE_WINDOWS // @TODO - struct StringTree : chowdsp::AbstractTree { static Node& insert_string (std::string&& element, Node& parent_node, AbstractTree& tree) @@ -161,4 +159,3 @@ TEST_CASE ("Abstract Tree Test", "[common][data-structures]") }); } } -#endif diff --git a/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp b/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp index fd6133e40..4dd90ef4c 100644 --- a/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp +++ b/tests/common_tests/chowdsp_data_structures_test/EnumMapTest.cpp @@ -93,9 +93,7 @@ TEST_CASE ("Enum Map Test", "[common][data-structures]") iter = 0; for (auto [key, val] : map) val = static_cast (iter++); -#if ! JUCE_WINDOWS // @TODO REQUIRE (map[Food::Apple] == 0); REQUIRE (map[Food::Green_Beans] == 1); -#endif } } diff --git a/tests/common_tests/chowdsp_data_structures_test/STLArenaAllocatorTest.cpp b/tests/common_tests/chowdsp_data_structures_test/STLArenaAllocatorTest.cpp index df8a9f212..017afca92 100644 --- a/tests/common_tests/chowdsp_data_structures_test/STLArenaAllocatorTest.cpp +++ b/tests/common_tests/chowdsp_data_structures_test/STLArenaAllocatorTest.cpp @@ -1,8 +1,6 @@ #include #include -#if ! JUCE_WINDOWS // @TODO - TEST_CASE ("STL Arena Allocator Test", "[common][data-structures]") { using Arena = chowdsp::ArenaAllocator<>; @@ -27,5 +25,3 @@ TEST_CASE ("STL Arena Allocator Test", "[common][data-structures]") REQUIRE (vec.size() == 5); REQUIRE (vec.front() == 0); } - -#endif