Magentix
if (OP.statement == false) postCount++;
- Reaction score
- 107
Have a look at this BJ:
Now, I've seen some people saying that if you call GetUnitsInRangeOfLocMatching you need to destroy the boolexpr you passed to it (the Condition() function return)...
However, it seems to me that the BJ destroys the boolexpr already, so my question is: Does it leak if, for example, I do this...
EDIT:
Would this be a non-leaking alternative to the BJ (since the BJ doesn't seem to null 'g')?
JASS:
function GetUnitsInRangeOfLocMatching takes real radius, location whichLocation, boolexpr filter returns group
local group g = CreateGroup()
call GroupEnumUnitsInRangeOfLoc(g, whichLocation, radius, filter)
call DestroyBoolExpr(filter)
return g
endfunction
Now, I've seen some people saying that if you call GetUnitsInRangeOfLocMatching you need to destroy the boolexpr you passed to it (the Condition() function return)...
However, it seems to me that the BJ destroys the boolexpr already, so my question is: Does it leak if, for example, I do this...
JASS:
function checkleak takes nothing returns nothing
local location l = Location(.0,.0)
local group g = GetUnitsInRangeOfLocMatching(250.,loc,Condition(function GroupCondition))
call ForGroup(g,function GroupCallback)
call DestroyGroup(g)
call RemoveLocation l
set g = null
set l = null
endfunction
EDIT:
Would this be a non-leaking alternative to the BJ (since the BJ doesn't seem to null 'g')?
JASS:
// Better GetUnitsInRangeOfLocMatching
function GetUnitsInRangeMatching_core takes group g, real radius, real x, real y, boolexpr filter returns group
call GroupEnumUnitsInRange(g, x, y, radius, filter)
call DestroyBoolExpr(filter)
return g
endfunction
function GetUnitsInRangeMatching takes real radius, real x, real y, boolexpr filter returns group
return GetUnitsInRangeMatching_core(CreateGroup(),radius,x,y,filter)
endfunction