I'm writing a stupidly complex set of jass scripts and tried to prevent as many leaks as possible. However, I'm concerned there's some really simple things that could leak. Like, is there a difference between the two test functions below?
function cache takes nothing returns gamecache
return udg_mycache
endfunction
function testA takes string s returns nothing
call StoreString(cache(), "something", "else", s)
endfunction
function testB takes string s returns nothing
local gamecache g = cache()
call StoreString(g, "something", "else", s)
set g = null
endfunction
And what about ignoring return values? I remember seeing that parameters don't need to be nulled, but do returns?
Leaks are saved "things" that are not being used, thus all they do is to take away memory. So returned values would not "leak", because you do something with that. Local variables have to be nullified, because even after the function is executed they stay the way they are. Nullifying a variable means removing stored values from a variable.