• 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 short code cause memory leak?

Status
Not open for further replies.
JASS:
function GetUnitsOfPlayerMatching takes player whichPlayer, boolexpr filter returns group
    local group g = CreateGroup()
    call GroupEnumUnitsOfPlayer(g, whichPlayer, filter)
    call DestroyBoolExpr(filter)
    return g
endfunction

function GetUnitsOfPlayerAll takes player whichPlayer returns group
    return GetUnitsOfPlayerMatching(whichPlayer, null)
endfunction
So yeah, your code leaks.

Instead of setting local group to new group handle (CreateGroup) and then resetting it to function return value (leak comes from there, you havent destoyed previously allocated handle object) you should do:
JASS:
local group g = GetUnitsOfPlayerAll(Player(0))
 
Status
Not open for further replies.
Top