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);