[JASS] Does i leak in function xxx takes item i returns something

Level 2
Joined
Jul 10, 2019
Messages
14
JASS:
function CollisionDetectionUnitGround takes item i, real xfo, real yfo returns boolean
    local real x
    local real y

    call SetItemPosition(i,xfo,yfo)
    set x=GetItemX(i)
    set y=GetItemY(i)
    call RemoveItem(i)
    if xfo==x and yfo==y then
        call DisplayTextToForce(GetPlayersAll(),"WORKS")
        return true
    else
        call DisplayTextToForce(GetPlayersAll(),"FAIL")
    endif
    return false
endfunction
JASS:
function testingblock takes nothing returns nothing
    local real x=GetUnitX(udg_mt)
    local real y=GetUnitY(udg_mt)
    local item i= CreateItem('afac',1,1)//not finished; will use hashtable instead of call RemoveItem(i)

    if CollisionDetectionUnitGround(i,x,y)==true then
        do something
    endif

    set i=null
endfunction

Example. The use of the functions themselves is irrelevant here.
What I am asking is:
do I need to set i=null in CollisionDetectionUnitGround()?
 
Last edited:
+1 based on available discussions and descriptions:
addition (for which I thank PTR153), if you create an object and assign it to a local, or create any object inside the function and assign it to a local variable, then it MUST BE nulled; if the created object was not removed and you continue to use it, then all that is needed is to assign it to some global variable and return it.
 
Back
Top