From 0cf55d36172ad676d49ece4368277a73a32d74dc Mon Sep 17 00:00:00 2001 From: elsid Date: Sat, 23 Dec 2023 18:37:48 +0100 Subject: [PATCH] Use RecastGlobalAllocator for Detour --- .../detournavigator/recastglobalallocator.hpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/components/detournavigator/recastglobalallocator.hpp b/components/detournavigator/recastglobalallocator.hpp index 956f050a72..f69805eb97 100644 --- a/components/detournavigator/recastglobalallocator.hpp +++ b/components/detournavigator/recastglobalallocator.hpp @@ -3,6 +3,7 @@ #include "recasttempallocator.hpp" +#include #include #include @@ -14,10 +15,14 @@ namespace DetourNavigator public: static void init() { instance(); } - static void* alloc(size_t size, rcAllocHint hint) + static void* recastAlloc(size_t size, rcAllocHint hint) { return alloc(size, hint == RC_ALLOC_TEMP); } + + static void* detourAlloc(size_t size, dtAllocHint hint) { return alloc(size, hint == DT_ALLOC_TEMP); } + + static void* alloc(size_t size, bool temp) { void* result = nullptr; - if (rcLikely(hint == RC_ALLOC_TEMP)) + if (rcLikely(temp)) result = tempAllocator().alloc(size); if (rcUnlikely(!result)) result = allocPerm(size); @@ -38,7 +43,11 @@ namespace DetourNavigator } private: - RecastGlobalAllocator() { rcAllocSetCustom(&RecastGlobalAllocator::alloc, &RecastGlobalAllocator::free); } + RecastGlobalAllocator() + { + rcAllocSetCustom(&RecastGlobalAllocator::recastAlloc, &RecastGlobalAllocator::free); + dtAllocSetCustom(&RecastGlobalAllocator::detourAlloc, &RecastGlobalAllocator::free); + } static RecastGlobalAllocator& instance() {