• 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.

[JASS] Does this leak?

Status
Not open for further replies.
Level 11
Joined
Oct 11, 2012
Messages
711
Hi guys, does the following code leak?
JASS:
function Trig_hInitializingActions takes nothing returns nothing
    local group g
    set g = CreatingSomeGroup
    call ForGroup(g, function callback)
    set g = CreatingSomeOtherGroup
    call ForGroup(g, function callback)
    call DestroyGroup(g)
    set g = null
endfunction

Or should I do this?
JASS:
function Trig_hInitializingActions takes nothing returns nothing
    local group g1 = CreatingSomeGroup
    local group g2 = CreatingSomeOtherGroup
    call ForGroup(g1, function callback)
    call DestroyGroup(g1)
    call ForGroup(g2, function callback)
    call DestroyGroup(g2)
    set g1 = null
    set g2 = null
endfunction
 
Last edited:
If you don't use function CreateGroup() in your function you can't say if you leak or not, because then obviosuly SomeGroup and SomeOtherGroup are globals.
And we can't see what else you would do with your globals.

But if you create groups in your function, then your 1st example would leak.

Anyway you would not need two local groups, you also could do:
JASS:
function Trig_hInitializingActions takes nothing returns nothing
    local group myGroup = SomeGroup

    call ForGroup(myGroup, function callback)
    call DestroyGroup(myGroup)

    set myGroup = SomeOtherGroup
    call ForGroup(myGroup, function callback)
    call DestroyGroup(myGroup)

    set myGroup = null
endfunction
 
Status
Not open for further replies.
Top