mirror of
https://github.com/brues-code/pfUI.git
synced 2026-09-28 02:16:02 +00:00
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.
This commit is contained in:
+7
-7
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user