From 737d776f24fc3f61b0b774ad0c12e6147cd43cc7 Mon Sep 17 00:00:00 2001 From: Georg Hagen Date: Thu, 17 Apr 2025 16:23:11 +0200 Subject: [PATCH] Fix issues with stablevector --- openVulkanoCpp/Data/Containers/StableVector.hpp | 7 +++---- tests/Data/Containers/StableVectorTest.cpp | 4 +--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/openVulkanoCpp/Data/Containers/StableVector.hpp b/openVulkanoCpp/Data/Containers/StableVector.hpp index b6044cb..e46c794 100644 --- a/openVulkanoCpp/Data/Containers/StableVector.hpp +++ b/openVulkanoCpp/Data/Containers/StableVector.hpp @@ -261,18 +261,17 @@ namespace OpenVulkano void PopBack() { - if (m_size == 0) - { - return; // return? or make - } + if (m_size == 0) return; if (m_lastChunk->m_nextIndex == 1 && m_lastChunk != m_firstChunk) { VectorChunk* temp = m_lastChunk; + m_capacity -= temp->m_capacity; m_lastChunk = m_lastChunk->m_prev; m_lastChunk->m_next = nullptr; temp->~VectorChunk(); ::operator delete(temp); + m_size--; return; } diff --git a/tests/Data/Containers/StableVectorTest.cpp b/tests/Data/Containers/StableVectorTest.cpp index edef5a8..29a65fb 100644 --- a/tests/Data/Containers/StableVectorTest.cpp +++ b/tests/Data/Containers/StableVectorTest.cpp @@ -90,15 +90,13 @@ TEST_CASE("ChunkVector") REQUIRE(vec.Size() == 100); - uint64_t tempVal = vec.Capacity(); - for (uint32_t i = 0; i < 50; ++i) { vec.PopBack(); } REQUIRE(vec.Size() == 50); - REQUIRE(vec.Capacity() == tempVal); + REQUIRE(vec.Capacity() == 32 + 64); } SECTION("Iterators with empty vector")