wc3edit.net

United Warcraft 3 map hacking!
It is currently April 18th, 2024, 8:25 pm

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: nulling local variables
PostPosted: April 30th, 2009, 9:20 pm 
Offline
Senior Member

Joined: February 15th, 2009, 9:08 pm
Posts: 185
Which variables do you have to set to null to prevent memory leaks?

I had been doing units and groups, but I saw someone else's map set local player variables to null too. Is this necessary?


Top
 Profile  
 
PostPosted: April 30th, 2009, 10:32 pm 
Offline
Forum Staff
User avatar

Joined: January 1st, 2008, 12:58 am
Posts: 862
Every handle except real / integer should be nulled. Special ones like groups should be DestroyGroup()'d first.

_________________
Image
Wanna learn to hack maps? --> Guide


Top
 Profile  
 
PostPosted: May 1st, 2009, 1:14 am 
Offline
Senior Member

Joined: February 15th, 2009, 9:08 pm
Posts: 185
I guess it's a good thing I don't use local players much then


Top
 Profile  
 
PostPosted: May 1st, 2009, 9:05 pm 
Offline
Forum Staff
User avatar

Joined: January 28th, 2007, 8:10 pm
Posts: 830
Location: Canada
Title: JASS Programmer
storyyeller wrote:
I guess it's a good thing I don't use local players much then


I use local players all the time.
Locals are much better as long as you remember to null handles.


Top
 Profile  
 
PostPosted: May 1st, 2009, 10:21 pm 
Offline
Senior Member

Joined: February 15th, 2009, 9:08 pm
Posts: 185
No, what I mean is that I use integers to refer to the player, since even if I used actual player variables, I'd jut have to convert to an integer whenever I wanted to index an array with it anyway

E.g. stuff like this
Code:
function whatever takes nothing returns nothing
    local integer p = GetPlayerId(GetTriggerPlayer())
    // do stuff here
endfunction


Top
 Profile  
 
PostPosted: May 2nd, 2009, 4:30 pm 
Offline
Forum Staff
User avatar

Joined: January 28th, 2007, 8:10 pm
Posts: 830
Location: Canada
Title: JASS Programmer
Aha, I see. I make a lot of spells and, as you can imagine, I use a lot of unit/player variables.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 13 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

phpBB SEO


Privacy Policy Statement
Impressum (German)