From e7dd8776f142a708e4677c1299ff89f1bcbe2baf Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 8 Mar 2017 22:14:44 +0100 Subject: [PATCH] api: fix memory leak very ugly, but lua5.0 doesn't handle '...' in an efficient way. By unpacking 'arg' inside of an OnUpdate function, the memory usage will increase dramatically. The supported count of arguments is now set statically to a maxium of 10. --- api/api.lua | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/api.lua b/api/api.lua index e0bd4116..1e3e882d 100644 --- a/api/api.lua +++ b/api/api.lua @@ -41,7 +41,7 @@ function pfUI.api.round(input, places) end end --- [ Hook ] +-- [ hooksecurefunc ] -- Hooks a global function and injects custom code -- 'name' [string] name of the function that shold be hooked -- 'func' [function] function containing the custom code @@ -55,14 +55,14 @@ function pfUI.api.hooksecurefunc(name, func, append) pfUI.hooks[tostring(func)]["new"] = func if append then - pfUI.hooks[tostring(func)]["function"] = function(...) - pfUI.hooks[tostring(func)]["old"](unpack(arg)) - pfUI.hooks[tostring(func)]["new"](unpack(arg)) + pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) + pfUI.hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) + pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) end else - pfUI.hooks[tostring(func)]["function"] = function(...) - pfUI.hooks[tostring(func)]["new"](unpack(arg)) - pfUI.hooks[tostring(func)]["old"](unpack(arg)) + pfUI.hooks[tostring(func)]["function"] = function(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) + pfUI.hooks[tostring(func)]["new"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) + pfUI.hooks[tostring(func)]["old"](a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) end end