Memory leak fixed

This commit is contained in:
Nekotekina 2014-12-01 03:41:01 +03:00
parent 697b699873
commit c61fe621b0
2 changed files with 27 additions and 35 deletions

View file

@ -2,42 +2,36 @@
#include "Emu/System.h" #include "Emu/System.h"
#include "PSVFuncList.h" #include "PSVFuncList.h"
std::vector<psv_func> g_psv_func_list = []() -> std::vector<psv_func> std::vector<psv_func> g_psv_func_list;
{
std::vector<psv_func> v;
psv_func unimplemented = void add_psv_func(psv_func& data)
{ {
0x00000000, // must not be a valid id if (!g_psv_func_list.size())
"INVALID FUNCTION", {
new psv_func_detail::func_binder<u32>([]() -> u32 psv_func unimplemented;
unimplemented.nid = 0x00000000; // must not be a valid id
unimplemented.name = "INVALID FUNCTION (0x0)";
unimplemented.func.reset(new psv_func_detail::func_binder<u32>([]() -> u32
{ {
LOG_ERROR(HLE, "Unimplemented function executed"); LOG_ERROR(HLE, "Unimplemented function executed");
Emu.Pause(); Emu.Pause();
return 0xffffffffu; return 0xffffffffu;
}), }));
nullptr, g_psv_func_list.push_back(unimplemented);
};
v.push_back(unimplemented);
psv_func hle_return = psv_func hle_return;
{ hle_return.nid = 0x00000001; // must not be a valid id
0x00000001, // must not be a valid id hle_return.name = "INVALID FUNCTION (0x1)";
"INVALID FUNCTION", hle_return.func.reset(new psv_func_detail::func_binder<void, ARMv7Thread&>([](ARMv7Thread& CPU)
new psv_func_detail::func_binder<void, ARMv7Thread&>([](ARMv7Thread& CPU)
{ {
CPU.FastStop(); CPU.FastStop();
}),
nullptr,
};
v.push_back(hle_return);
return v; return;
}(); }));
g_psv_func_list.push_back(hle_return);
}
void add_psv_func(psv_func& data)
{
g_psv_func_list.push_back(data); g_psv_func_list.push_back(data);
} }

View file

@ -643,10 +643,10 @@ namespace psv_func_detail
struct psv_func struct psv_func
{ {
const u32 nid; u32 nid;
const char* const name; const char* name;
psv_func_caller* const func; std::shared_ptr<psv_func_caller> func;
psv_log_base* const module; psv_log_base* module;
}; };
void add_psv_func(psv_func& data); void add_psv_func(psv_func& data);
@ -654,13 +654,11 @@ void add_psv_func(psv_func& data);
template<typename RT, typename... T> template<typename RT, typename... T>
void reg_psv_func(u32 nid, psv_log_base* module, const char* name, RT(*func)(T...)) void reg_psv_func(u32 nid, psv_log_base* module, const char* name, RT(*func)(T...))
{ {
psv_func f = psv_func f;
{ f.nid = nid;
nid, f.name = name;
name, f.func.reset(new psv_func_detail::func_binder<RT, T...>(func));
new psv_func_detail::func_binder<RT, T...>(func), f.module = module;
module
};
add_psv_func(f); add_psv_func(f);
} }