lol wow two different responses, but i believe purge more
The replies are the same.
Purge just understood something differently, that's all.
If you use
local location L
, it will not give a handle leak.
However: if you then use
set L = Location
or simply do
local location L = Location
, it will leak.
It's highly unlikely that you will just do this:
JASS:
function loc takes nothing returns nothing
local location l
set l = null
endfunction
This is what Purge said: since the location isn't used, it doesn't create a handle leak and you don't need to remove anything.
The function above is leakless (no RemoveLocation required).
what ikillforyou said is basically this:
JASS:
function loc takes nothing returns nothing
local location l = Location
call RemoveLocation(l)
set l = null
endfunction
It's very obvious: you're creating a local variable, so you're probably going to set it to a location as well.
Therefore, it
will leak, because it accesses a handle (a location in this case).
If you're going to create a local wihout actually setting it to something (like in the first function), don't create it, it's as simple as that.
Therefore I think Purge is wrong (he said it doesn't leak, which is correct, but why nullify it then? Just removing the entire variable would be the best option in that case).
On the other hand: don't use locations either.
Use coördinates (reals): they don't give handle leaks and you wouldn't have this problem in the first place.
JASS:
function loc takes nothing returns nothing
local real X = GetUnitX(unit)
local real Y = GetUnitY(unit)
endfunction
Like this.
No locations, no handle leaks.