diff --git a/src/Utils/Memory.cpp b/src/Utils/Memory.cpp index 9b3a0910..ceab4894 100644 --- a/src/Utils/Memory.cpp +++ b/src/Utils/Memory.cpp @@ -4,7 +4,7 @@ namespace Utils { Utils::Memory::Allocator Memory::MemAllocator; - void* Memory::AllocateAlign(size_t length, size_t alignment) + void* Memory::AllocateAlign(std::size_t length, std::size_t alignment) { auto* data = _aligned_malloc(length, alignment); assert(data); @@ -12,9 +12,9 @@ namespace Utils return data; } - void* Memory::Allocate(size_t length) + void* Memory::Allocate(std::size_t length) { - auto* data = calloc(length, 1); + auto* data = std::calloc(length, 1); assert(data); return data; } @@ -28,10 +28,7 @@ namespace Utils void Memory::Free(void* data) { - if (data) - { - ::free(data); - } + std::free(data); } void Memory::Free(const void* data) @@ -53,11 +50,11 @@ namespace Utils } // Complementary function for memset, which checks if memory is filled with a char - bool Memory::IsSet(void* mem, char chr, size_t length) + bool Memory::IsSet(void* mem, char chr, std::size_t length) { auto* memArr = static_cast(mem); - for (size_t i = 0; i < length; ++i) + for (std::size_t i = 0; i < length; ++i) { if (memArr[i] != chr) { diff --git a/src/Utils/Memory.hpp b/src/Utils/Memory.hpp index 7d3fc150..3e85c756 100644 --- a/src/Utils/Memory.hpp +++ b/src/Utils/Memory.hpp @@ -73,7 +73,7 @@ namespace Utils this->refMemory[memory] = callback; } - void* allocate(size_t length) + void* allocate(std::size_t length) { std::lock_guard _(this->mutex); @@ -87,7 +87,7 @@ namespace Utils return this->allocateArray(1); } - template T* allocateArray(size_t count = 1) + template T* allocateArray(std::size_t count = 1) { return static_cast(this->allocate(count * sizeof(T))); } @@ -133,13 +133,13 @@ namespace Utils std::unordered_map refMemory; }; - static void* AllocateAlign(size_t length, size_t alignment); - static void* Allocate(size_t length); + static void* AllocateAlign(std::size_t length, std::size_t alignment); + static void* Allocate(std::size_t length); template static T* Allocate() { return AllocateArray(1); } - template static T* AllocateArray(size_t count = 1) + template static T* AllocateArray(std::size_t count = 1) { return static_cast(Allocate(count * sizeof(T))); } @@ -159,7 +159,7 @@ namespace Utils static void FreeAlign(void* data); static void FreeAlign(const void* data); - static bool IsSet(void* mem, char chr, size_t length); + static bool IsSet(void* mem, char chr, std::size_t length); static bool IsBadReadPtr(const void* ptr); static bool IsBadCodePtr(const void* ptr);