From 5b0d9e7d074f82586ab808ee2888c543b03ceec1 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Tue, 9 Aug 2016 08:17:04 -0400 Subject: [PATCH] . --- toolbox/mm.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/toolbox/mm.cpp b/toolbox/mm.cpp index 1cb84b3..74b5091 100644 --- a/toolbox/mm.cpp +++ b/toolbox/mm.cpp @@ -106,17 +106,7 @@ namespace namespace MM { - - template - struct tool_return_type { typedef tool_return type; }; - - template<> - struct tool_return_type { typedef tool_return type; }; - - - template - struct tool_return_type> { typedef tool_return type; }; - + using MacOS::tool_return_type; template T with_handle_helper(F &&f, HandleInfo &info, typename std::enable_if::value>::type* = 0) { @@ -137,12 +127,11 @@ namespace MM typename TRT = typename tool_return_type::type> // tool return type. TRT __with_handle(uint32_t handle, F &&f) { + if (handle == 0) return SetMemError(MacOS::nilHandleErr); + const auto iter = HandleMap.find(handle); - if (iter == HandleMap.end()) { - TRT rv = SetMemError(MacOS::memWZErr); - return rv; - } + if (iter == HandleMap.end()) return SetMemError(MacOS::memWZErr); auto &info = iter->second; TRT rv = with_handle_helper(std::forward(f), info);