diff --git a/TR5Main/Game/memory/malloc.cpp b/TR5Main/Game/memory/malloc.cpp index 9193bcbe6..026f99caf 100644 --- a/TR5Main/Game/memory/malloc.cpp +++ b/TR5Main/Game/memory/malloc.cpp @@ -12,12 +12,12 @@ int malloc_used; using namespace T5M::Memory; MemoryPool* gameMemory; -void init_game_malloc() +void init_game_malloc() noexcept { - gameMemory = new MemoryPool(MemoryUnit::MebiByte, 512, 256); + gameMemory = new MemoryPool(MemoryUnit::MebiByte, 196, 128); } -void game_free(void* ptr) +void game_free(void* ptr) noexcept { gameMemory->free(ptr); } \ No newline at end of file diff --git a/TR5Main/Game/memory/malloc.h b/TR5Main/Game/memory/malloc.h index 01d2f5637..2fe9b849f 100644 --- a/TR5Main/Game/memory/malloc.h +++ b/TR5Main/Game/memory/malloc.h @@ -8,9 +8,8 @@ extern int malloc_free; extern int malloc_used; extern T5M::Memory::MemoryPool* gameMemory; template -T* game_malloc(size_t count= 1) { +[[nodiscard]] T* game_malloc(size_t count= 1) noexcept { return gameMemory->malloc(count); } - -void init_game_malloc(); -void game_free(void* ptr); \ No newline at end of file +void init_game_malloc() noexcept; +void game_free(void* ptr) noexcept; \ No newline at end of file diff --git a/TR5Main/Game/memory/qmalloc.h b/TR5Main/Game/memory/qmalloc.h index 56e0bfa72..e6d7a1824 100644 --- a/TR5Main/Game/memory/qmalloc.h +++ b/TR5Main/Game/memory/qmalloc.h @@ -18,6 +18,7 @@ namespace T5M::Memory { static constexpr unsigned int MALLOC_MAGIC = 0xDEADBEEF; public: + //Creates a Memory Pool with the specified memory and page size. The memory also contains the metadata and house keeping MemoryPool(MemoryUnit unit, size_t amount, size_t pageSize) : pageSize(pageSize), size(static_cast(unit)* amount), arena(new uint8_t[size]{0}) { init(); } @@ -34,7 +35,8 @@ namespace T5M::Memory { * Reserves Memory of type T with an additional count **/ template - T* malloc(size_t count = 1) { + [[nodiscard]] T* malloc(size_t count = 1) noexcept { + if (count < 1) return nullptr; int pages; int n;