Yet, another leak question

XeRo13g

New Member
Reaction score
3
JASS:
function 2 takes nothing returns nothing
local timer t=GetExpiredTimer()
   (do something)
   call PauseTimer(t)
   call DestroyTimer(t)
   set t=null
endfunction

function 1 takes nothing returns nothing
local effect sfx
local timer t

if (condition==true) then
   set sfx=AddSpecialEffect("any effect",x,y)
   set t=CreateTimer()
   (use sfx)
   call DestroyEffect(sfx)
   set sfx=null
   call TimerStart(t,5.,false,function 2)
   set t=null
else
    (other actions)
endif
endfunction


Does function 1 leak the two handles(sfx,timer) in case the condition is false?
Should I use a null value for both at their declaration?

Thanks in advance.-
 

luorax

Invasion in Duskwood
Reaction score
67
No, they won't leak; you only have to null them if you give them value (besides null)
 

Dirac

22710180
Reaction score
147
a few tips
[ljass]call DestroyEffect(AddSpecialEffect("any effect",x,y))[/ljass] to avoid local var usage
[ljass]call TimerStart(CreateTimer(),5.,false,function 2)[/ljass] to avoid local var usage
[ljass]call DestroyTimer(GetExpiredTimer())[/ljass] no need to pause the timer when destroyed.
 

XeRo13g

New Member
Reaction score
3
Thanks guys, that clear things up.

PS. I can't give rep to any of you. I'll get back to that asap.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top