diff options
Diffstat (limited to 'src/core/hle/service/service.cpp')
-rw-r--r-- | src/core/hle/service/service.cpp | 28 |
1 files changed, 10 insertions, 18 deletions
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index e6605a398..08d0c43ff 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -7,12 +7,15 @@ #include "common/string_util.h" #include "core/hle/hle.h" + #include "core/hle/service/service.h" #include "core/hle/service/apt.h" #include "core/hle/service/gsp.h" #include "core/hle/service/hid.h" #include "core/hle/service/srv.h" +#include "core/hle/kernel/kernel.h" + namespace Service { Manager* g_manager = NULL; ///< Service manager @@ -31,32 +34,21 @@ Manager::~Manager() { /// Add a service to the manager (does not create it though) void Manager::AddService(Interface* service) { - int index = m_services.size(); - u32 new_uid = GetUIDFromIndex(index); - + m_port_map[service->GetPortName()] = Kernel::g_object_pool.Create(service); m_services.push_back(service); - - m_port_map[service->GetPortName()] = new_uid; - service->m_uid = new_uid; } /// Removes a service from the manager, also frees memory void Manager::DeleteService(std::string port_name) { - auto service = FetchFromPortName(port_name); - - m_services.erase(m_services.begin() + GetIndexFromUID(service->m_uid)); + Interface* service = FetchFromPortName(port_name); + m_services.erase(std::remove(m_services.begin(), m_services.end(), service), m_services.end()); m_port_map.erase(port_name); - delete service; } -/// Get a Service Interface from its UID -Interface* Manager::FetchFromUID(u32 uid) { - int index = GetIndexFromUID(uid); - if (index < (int)m_services.size()) { - return m_services[index]; - } - return NULL; +/// Get a Service Interface from its Handle +Interface* Manager::FetchFromHandle(Handle handle) { + return Kernel::g_object_pool.GetFast<Interface>(handle); } /// Get a Service Interface from its port @@ -65,7 +57,7 @@ Interface* Manager::FetchFromPortName(std::string port_name) { if (itr == m_port_map.end()) { return NULL; } - return FetchFromUID(itr->second); + return FetchFromHandle(itr->second); } |