Simple leak question

Doom-Angel

Jass User (Just started using NewGen)
Reaction score
167
i think it does since u are still calling a location which is not framed in a variable but from the other side that value goes stright to the function u call so it's realy is confusion though....
so im gonna join ur question.
 

Sim

Forum Administrator
Staff member
Reaction score
534
The location has to be created somehow, and if you don't remove it...
 

SFilip

Gone but not forgotten
Reaction score
634
Code from the first post - doesn't leak.
However I discourage making functions this way from a simple reason
JASS:
function Omni takes nothing returns nothing
    local location l = GetUnitLoc(someunit)
    call Doesthisleak(l)
    call CreateUnitAtLoc(Player(0), 'hfoo', l, 0.00)
endfunction

It doesn't leak, but the second unit will most likely appear at the center of the map since l is destroyed at that point.
Nothing really wrong, but this would certainly be confusing for me to work with so I suggest that you avoid fixing leaks this way.
 

Omni

Ultra Cool Member
Reaction score
37
Code from the first post - doesn't leak.

But would it if there wasnt a "call RemoveLocation(Do_I_Leak)" in it?
I guess so *looking at ForGroupBJ*

and i know a can avoid leaks a better way, lol this was just an example of what i meant. (anyway ty)
 

SFilip

Gone but not forgotten
Reaction score
634
> if there wasnt a "call RemoveLocation(Do_I_Leak)"
Then it would.

Now if you are curious on how this whole thing works...every handle-derived type (units, locations, groups...) is in fact an integer, kind of an address that points to where the actual data is located (in case of units the type, hp, mp, in case of locations the coordinates etc). When you specify a variable like this as a parameter you copy only this address and pass it to the function. This is why they are in fact the same thing, only seemingly stored in different variables.
 
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