diff --git a/source/lib/allocators/DynamicArena.h b/source/lib/allocators/DynamicArena.h index d4ff273d58..40d26209ca 100644 --- a/source/lib/allocators/DynamicArena.h +++ b/source/lib/allocators/DynamicArena.h @@ -126,7 +126,7 @@ public: m_Blocks.emplace_back(); } - void* allocate(size_t n, const void*, size_t alignment) + void* allocate(size_t n, size_t alignment) { // Safely handle zero-sized allocations (happens with GCC STL - see ticket #909). if (n == 0) diff --git a/source/lib/allocators/STLAllocators.h b/source/lib/allocators/STLAllocators.h index c8040d8bd9..e93dbba843 100644 --- a/source/lib/allocators/STLAllocators.h +++ b/source/lib/allocators/STLAllocators.h @@ -58,7 +58,7 @@ public: T* allocate(size_t n) { - return static_cast(allocator->allocate(n * sizeof(T), nullptr, alignof(T))); + return static_cast(allocator->allocate(n * sizeof(T), alignof(T))); } void deallocate(T* ptr, const size_t n) @@ -102,7 +102,7 @@ public: T* allocate(size_t n) { - return static_cast(allocator.allocate(n * sizeof(T), nullptr, alignof(T))); + return static_cast(allocator.allocate(n * sizeof(T), alignof(T))); } void deallocate(T* ptr, const size_t n) @@ -110,6 +110,18 @@ public: return allocator.deallocate(static_cast(ptr), n * sizeof(T)); } + template + bool operator==(const ProxyAllocator& other) const + { + return std::addressof(allocator) == std::addressof(other.allocator); + } + + template + bool operator!=(const ProxyAllocator& other) const + { + return std::addressof(allocator) != std::addressof(other.allocator); + } + private: Backend& allocator; }; diff --git a/source/lib/allocators/tests/test_DynamicArena.h b/source/lib/allocators/tests/test_DynamicArena.h index 16c706236d..49c528fc4d 100644 --- a/source/lib/allocators/tests/test_DynamicArena.h +++ b/source/lib/allocators/tests/test_DynamicArena.h @@ -31,46 +31,46 @@ public: void test_allocate() { Allocators::DynamicArena<100> testArena; - u8* p = static_cast(testArena.allocate(10, nullptr, 1)); + u8* p = static_cast(testArena.allocate(10, 1)); TS_ASSERT(p != nullptr); - void* p2 = testArena.allocate(10, nullptr, 1); + void* p2 = testArena.allocate(10, 1); TS_ASSERT(p + 10 == p2); - void* p3 = testArena.allocate(80, nullptr, 1); + void* p3 = testArena.allocate(80, 1); TS_ASSERT(p + 20 == p3); - void* p4 = testArena.allocate(100, nullptr, 1); + void* p4 = testArena.allocate(100, 1); TS_ASSERT(p4 != nullptr); - void* p5 = testArena.allocate(1, nullptr, 1); + void* p5 = testArena.allocate(1, 1); TS_ASSERT(p5 != nullptr); - void* p6 = testArena.allocate(100, nullptr, 1); + void* p6 = testArena.allocate(100, 1); TS_ASSERT(p6 != nullptr); - void* p7 = testArena.allocate(0, nullptr, 1); + void* p7 = testArena.allocate(0, 1); TS_ASSERT(p7 != nullptr); } void test_alignment() { Allocators::DynamicArena<100> testArena; - u8* p = static_cast(testArena.allocate(4, nullptr, 1)); + u8* p = static_cast(testArena.allocate(4, 1)); TS_ASSERT(p != nullptr); - u8* p2 = static_cast(testArena.allocate(1, nullptr, 8)); + u8* p2 = static_cast(testArena.allocate(1, 8)); TS_ASSERT_EQUALS(p + 8, p2); - p2 = static_cast(testArena.allocate(1, nullptr, 8)); + p2 = static_cast(testArena.allocate(1, 8)); TS_ASSERT_EQUALS(p + 16, p2); - p2 = static_cast(testArena.allocate(1, nullptr, 8)); + p2 = static_cast(testArena.allocate(1, 8)); TS_ASSERT_EQUALS(p + 24, p2); - p2 = static_cast(testArena.allocate(1, nullptr, 2)); + p2 = static_cast(testArena.allocate(1, 2)); TS_ASSERT_EQUALS(p + 26, p2); - p2 = static_cast(testArena.allocate(1, nullptr, 8)); + p2 = static_cast(testArena.allocate(1, 8)); TS_ASSERT_EQUALS(p + 32, p2); } }; diff --git a/source/ps/memory/LinearAllocator.h b/source/ps/memory/LinearAllocator.h index d687b82b98..4fd3f9f4a3 100644 --- a/source/ps/memory/LinearAllocator.h +++ b/source/ps/memory/LinearAllocator.h @@ -57,7 +57,7 @@ public: Release(); } - void* allocate(std::size_t n, void*, std::size_t alignment) + void* allocate(std::size_t n, std::size_t alignment) { m_Size = ROUND_UP(m_Size, alignment); if (m_Size + n > m_Capacity)