Skip to content

Commit

Permalink
Fix Allocator issues reported by ReSharper
Browse files Browse the repository at this point in the history
- no public virtual destructor inside Allocator (required for the rest of the classes, simply removed protected destructor as one is already present in IAllocator and it was defaulted)
- missing template keyword calling dependent function name
- missing default initialization for AllocationResult
  • Loading branch information
WSSDude committed Jan 12, 2025
1 parent 1f6f3cc commit 9483d00
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions include/RED4ext/Memory/Allocators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ RED4EXT_ASSERT_SIZE(AllocationResult, 0x10);

struct IAllocator
{
virtual ~IAllocator() = default;
virtual AllocationResult Alloc(uint32_t aSize) const = 0; // 00
virtual AllocationResult AllocAligned(uint32_t aSize, uint32_t aAlignment) const = 0; // 08
virtual AllocationResult Realloc(AllocationResult& aAllocation, uint32_t aSize) const = 0; // 10
Expand Down Expand Up @@ -81,9 +82,9 @@ struct Allocator : IAllocator
static UniversalRelocFunc<alloc_t> alloc(Detail::AddressHashes::Memory_Vault_Alloc);

auto pool = T::Get();
auto storage = pool->storage->GetAllocatorStorage<Vault>();
auto storage = pool->storage->template GetAllocatorStorage<Vault>();

AllocationResult result;
AllocationResult result = {};
alloc(storage, &result, aSize);
if (!result.memory)
{
Expand All @@ -99,9 +100,9 @@ struct Allocator : IAllocator
static UniversalRelocFunc<alloc_t> alloc(Detail::AddressHashes::Memory_Vault_AllocAligned);

auto pool = T::Get();
auto storage = pool->storage->GetAllocatorStorage<Vault>();
auto storage = pool->storage->template GetAllocatorStorage<Vault>();

AllocationResult result;
AllocationResult result = {};
alloc(storage, &result, aSize, aAlignment);
if (!result.memory)
{
Expand All @@ -117,9 +118,9 @@ struct Allocator : IAllocator
static UniversalRelocFunc<realloc_t> realloc(Detail::AddressHashes::Memory_Vault_Realloc);

auto pool = T::Get();
auto storage = pool->storage->GetAllocatorStorage<Vault>();
auto storage = pool->storage->template GetAllocatorStorage<Vault>();

AllocationResult result;
AllocationResult result = {};
realloc(storage, &result, aAllocation, aSize);
if (!result.memory && aSize)
{
Expand All @@ -136,9 +137,9 @@ struct Allocator : IAllocator
static UniversalRelocFunc<realloc_t> realloc(Detail::AddressHashes::Memory_Vault_ReallocAligned);

auto pool = T::Get();
auto storage = pool->storage->GetAllocatorStorage<Vault>();
auto storage = pool->storage->template GetAllocatorStorage<Vault>();

AllocationResult result;
AllocationResult result = {};
realloc(storage, &result, aAllocation, aSize, aAlignment);
if (!result.memory && aSize)
{
Expand All @@ -154,7 +155,7 @@ struct Allocator : IAllocator
static UniversalRelocFunc<func_t> func(Detail::AddressHashes::Memory_Vault_Free);

auto pool = T::Get();
auto storage = pool->storage->GetAllocatorStorage<Vault>();
auto storage = pool->storage->template GetAllocatorStorage<Vault>();
func(storage, aAllocation);
}

Expand All @@ -164,7 +165,7 @@ struct Allocator : IAllocator
static UniversalRelocFunc<func_t> func(Detail::AddressHashes::Memory_Vault_Unk1);

auto pool = T::Get();
auto storage = pool->storage->GetAllocatorStorage<Vault>();
auto storage = pool->storage->template GetAllocatorStorage<Vault>();
func(storage, a2);
}

Expand All @@ -179,7 +180,6 @@ struct Allocator : IAllocator

protected:
Allocator() = default;
~Allocator() = default;

private:
inline void OOM(uint32_t aSize, uint32_t aAlignment) const
Expand Down

0 comments on commit 9483d00

Please sign in to comment.