From d2d3457b2fd0635e3a32a701bd0b2d17b0374b4a Mon Sep 17 00:00:00 2001 From: Shauren Date: Tue, 1 Oct 2024 21:03:44 +0200 Subject: Core/Utilities: Extend make_unique_ptr_with_deleter functionality to allow it to create deleters with compile time constant functions (reduces its size to just sizeof(void*)) (cherry picked from commit b13b5142f1009a71ff06786ac8c8db92891f566a) --- src/common/Collision/Maps/MapTree.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/common/Collision/Maps/MapTree.cpp') diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index bde07b30065..d828326806c 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -196,11 +196,11 @@ namespace VMAP struct TileFileOpenResult { - using FileHandle = decltype(Trinity::make_unique_ptr_with_deleter(nullptr, &::fclose)); + using FileDeleter = decltype(Trinity::unique_ptr_deleter()); std::string Name; - FileHandle TileFile = { nullptr, &::fclose }; - FileHandle SpawnIndicesFile = { nullptr, &::fclose }; + std::unique_ptr TileFile; + std::unique_ptr SpawnIndicesFile; int32 UsedMapId; explicit operator bool() const { return TileFile && SpawnIndicesFile; } @@ -239,7 +239,7 @@ namespace VMAP basePath.push_back('/'); std::string fullname = basePath + VMapManager2::getMapFileName(mapID); - auto rf = Trinity::make_unique_ptr_with_deleter(fopen(fullname.c_str(), "rb"), &::fclose); + auto rf = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(fullname.c_str(), "rb")); if (!rf) return LoadResult::FileNotFound; @@ -263,7 +263,7 @@ namespace VMAP { TC_LOG_DEBUG("maps", "StaticMapTree::InitMap() : initializing StaticMapTree '{}'", fname); std::string fullname = iBasePath + fname; - auto rf = Trinity::make_unique_ptr_with_deleter(fopen(fullname.c_str(), "rb"), &::fclose); + auto rf = Trinity::make_unique_ptr_with_deleter<&::fclose>(fopen(fullname.c_str(), "rb")); if (!rf) return LoadResult::FileNotFound; -- cgit v1.2.3