| 03-07-2010, 12:16 PM | #1 |
JASS:function GetUnitsOfTypeIdAll takes integer unitid returns group local group result = CreateGroup() local group g = CreateGroup() local integer index set index = 0 loop set bj_groupEnumTypeId = unitid call GroupClear(g) call GroupEnumUnitsOfPlayer(g, Player(index), filterGetUnitsOfTypeIdAll) call GroupAddGroup(g, result) set index = index + 1 exitwhen index == bj_MAX_PLAYER_SLOTS endloop call DestroyGroup(g) return result endfunction This is a function included in Blizzard's API; there are a few things rather strange about it. First of all, filterGetUnitsOfTypeIdAll is shown as a constant (and highlighted in my JNGP) but I can't seem to find it anywhere. Also, I was very curious about this; notice how it returns result at the end of the function? Would that cause a leak in memory when the reference "result" becomes un-used? |
| 03-07-2010, 04:13 PM | #2 |
The global is in blizzard.j: JASS:set filterGetUnitsOfTypeIdAll = Filter(function GetUnitsOfTypeIdAllFilter) And blizzard has lots of leaky functions. Edited because: I copied the wrong line. Whoops.. JASS:boolexpr filterGetUnitsOfTypeIdAll = null |
| 03-07-2010, 08:04 PM | #3 |
result is obviously a global so it shouldn't leak. |
| 03-07-2010, 08:09 PM | #4 | ||||||
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
| 03-07-2010, 08:11 PM | #5 | |
I felt like I was being zoomed in. Quote:
Obviously. |
| 03-08-2010, 12:53 AM | #6 |
Fleder is obviously blind *blush* Anyway, since it returns a created group, it will leak unless you destroy it when you are done with it. |
| 03-08-2010, 02:07 AM | #7 |
JASS:local group g1 = CreateGroup() local group g2 = CopyGroup(g1) They both act the same way, and both need to be destroyed the same way. |
