Question about unit and location variable leaks when they are in a loop...see partial code below:
Where should the unit variable and location variable be nulled to prevent this function from leaking? Within the loop or at end of function?
JASS:
function example takes nothing returns nothing
local group g = CreateGroup()
local unit u
local location l
//code here to add units to group, omitted for clarity
loop
set u = FirstOfGroup(g)
exitwhen u == null
set l = //some location, different each time the loop runs
//code to have unit do something with location
call GroupRemoveUnit(g, u)
//Do I need to null the unit and/or location variable here to prevent from leaking on the next iteration of the loop?
//Or is it only necessary to do that at the end of the function?
endloop
call GroupClear(g)
call DestroyGroup(g)
set g = null
call RemoveLocation(l)
set u = null
endfunction
Where should the unit variable and location variable be nulled to prevent this function from leaking? Within the loop or at end of function?