Boolexpr leak?

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Have a look at this BJ:

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
 

saw792

Is known to say things. That is all.
Reaction score
280
You really would be much better off just using
[ljass]call GroupEnumUnitsInRange(g, x, y, radius, filter)[/ljass] with a single global group for all enumerations and running your actions in the filter function (returning false at the end). This avoids the group nulling problem altogether.

Boolexpr don't leak, you don't need to destroy them (unless using the And() or Or() functions, which nobody does anyway).
 

Magentix

if (OP.statement == false) postCount++;
Reaction score
107
Hmm roger, going to use a global group then.

If I'm not mistaken, I should ONLY use the global group for actions that I want to perform on a group I don't intend to save to a local variable, right?

(Otherwise with sleep actions, groups could get mixed up)
 

saw792

Is known to say things. That is all.
Reaction score
280
Well you shouldn't be using sleep actions anyway... but yeah, if you do decide to store a group for longer than instant enumeration actions you will have to be aware of it being overwritten/messed with in timer callbacks/sleeps. Most people don't use groups for anything other than instant enumerations.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Boolexpressions don't leak anymore (At least blizzard stated that ...).
'Real' Filter functions did never leak. It was just a null boolean expression that was leaking in the past and could be avoided using this little snippet called Boolexpr Utils.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top