• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[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