HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

This leaks?

03-03-2007, 12:05 AM#1
grupoapunte
Hey i want to know if this leaks, im prety sure it doesn't cuz the location is being pointed by a global:

Collapse JASS:
function ReturnLocation takes nothing returns location
    return udg_Location
endfunction

function Test takes nothing returns nothing
    call CreateUnitAtLocSaveLast(Player(0), 'h001', ReturnLocation(), bj_UNIT_FACING)
endfunction

I know it looks stupid but thats just a sample, in my real trigger the function that returns the location takes an integer that uses as index to select one of 10 diferent global arrays of locations.

So the question is, if i store the location in a local and then use RemoveLocation, it should remove the location which the global was pointing to, right?

Thanks!
03-03-2007, 02:01 AM#2
WNxCryptic
No, that won't leak since your working with a global..

But that's not an appropriate example if your real function takes an integer or other things, because if you don't appropriately de-allocate them at the end of the function, they will leak...if your actual function is more complicated, or if your still confused on leaks and whatnot, post back with the actual code, and we can tell you whether it leaks and where.
03-03-2007, 02:23 AM#3
Rising_Dusk
As long as you remove the location when/if you change the value of the global, it will not leak.
03-03-2007, 02:59 AM#4
Tossrock
If you use Vex's optimizer, that'll inline to udg_Location anyway.