| 08-26-2006, 10:42 PM | #1 |
Ok, here's the thing, I wanted to know if the following leaks or not, and how viable it is to use. The first example: JASS:function whatever2 takes location loc returns nothing ... call RemoveLocation(loc) endfunction function whatever takes nothing returns nothing local location pos = GetUnitLoc(gg_unit_h002_0009) //some hypothetical unit ... call whatever2(pos) set pos = null endfunction The second example: JASS:function whatever2 takes location loc returns nothing ... call RemoveLocation(loc) set loc = null endfunction function whatever takes nothing returns nothing ... call whatever2(GetUnitLoc(gg_unit_h002_0009)) endfunction About the first one: For one, I know it gets rid of the location stored under pos, but I don't know if it cleaned the way it should, and also, even if this killed the location the way it was supposed to, would I have to null both pos and loc in their respective funcs? And the more important question, on which types does this work on? Or not work on if there's less of 'em The second one is a lot more probable to leak, but that why I need an expert oppinion ![]() |
| 08-26-2006, 11:20 PM | #2 |
I can confirm that 'loc' never needs to be nulled. Function parameters don't ever need to be nulled. Not in the first example, not in the second. Also, since the variable pos and loc both point to the same place in memory where the location's coordinates are stored, removing it anywhere will remove it everywhere. Groups and all other handles that need to be destroyed share similar characteristics. To be fair, from where I'm sitting, neither leaks at all. |
| 08-26-2006, 11:39 PM | #3 |
Ok, I thought as much, but still needed some second oppinions. Anyone else able to confirm this just so I can feel safe using it? ![]() |
| 08-26-2006, 11:49 PM | #4 |
Now that you brought it up, does player variable needs to be nulled? |
| 08-26-2006, 11:55 PM | #5 |
No, player locals do not need to be nulled. |
| 08-27-2006, 12:21 AM | #6 |
You can still null them though. As for the examples in the first post, according to my knowledge they won't leak. |
| 08-27-2006, 03:36 AM | #7 |
They won't leak because you can't create players on the fly (and let their handle rot in stack space), they all point to the fixed amount of players the engine provides (15?). |
| 08-27-2006, 04:42 AM | #8 |
16 players actually. 0-15 all inclusive. |
