Do returning a local leaks its handle?

Yoww89

New Member
Reaction score
0
JASS:

function Leak takes nothing returns unit
    local unit u = whatever
    return u
    //the function stops here so there's no point in adding a "set u = null", but does it leak?
endfunction
 

TheLegend

New Member
Reaction score
10
no it doesnt leak, and even if it did leak you couldnt remove the leak since after return you cant write anything
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
no it doesnt leak, and even if it did leak you couldnt remove the leak since after return you cant write anything

Actually, yes it does. There's no exception to the bug that local variables do not decrease their reference counter when they go out of scope. You can get around it by moving it into a global variable, the most simplest way in this situation being putting into the [ljass]bj_lastCreatedUnit[/ljass].
 

Accname

2D-Graphics enthusiast
Reaction score
1,462
Depends on the local variable.
The simple kinds of variables like integers, characters, reals and so on do not leak. In a return statement it isnt their reference (thats the pointer to the specific position in your ram) which is returned but their actual value.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top