• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Does param location l leak?

Status
Not open for further replies.
Level 15
Joined
Nov 30, 2007
Messages
1,202
Does this leak a location?

JASS:
method spawn takes player p, real x, real y, location l returns nothing 
            local integer i = 0
            local integer j
            local unit u
            loop
                set j = 0
                loop
                    set u = CreateUnit(p, .u[i].unitTypeId, x, y, 0)
                    call IssuePointOrderLoc(u, "attack", l)
                    set j = j + 1
                    exitwhen j >= .u[i].amount
                endloop
                set i = i + 1
                exitwhen i >= .index
            endloop
            set u = null
        endmethod

JASS:
private function OnFinish takes nothing returns boolean
        local unit u = GetTrainedUnit()
        local integer i = Squad.getIndex(GetUnitTypeId(u))
        local location l 
        if i > 0 then 
            set l = GetUnitRallyPoint(GetTriggerUnit())
            call squad[i].spawn(GetTriggerPlayer(), GetUnitX(u), GetUnitY(u), l)
            call RemoveLocation(l)
            set l = null
        endif
        set u = null
        return false
    endfunction
 
Level 22
Joined
Feb 6, 2014
Messages
2,466
1st part
As far as I know, youbdid not create a new location and only used the location as a function's parameter so no, it does not leak.
2nd part
You used the RemoveLocation within the if statements that the location was created and you nulled the variable so it also does not leak.
 
Status
Not open for further replies.
Top