• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Jass Functions - Do they Need a Space? (Or Memory Leak?)

Status
Not open for further replies.
http://www.hiveworkshop.com/forums/world-editor-help-zone-98/player-group-leak-173958/

does this mean with all jass destructor functions, we have to use a space or it will leak? I was unaware of this, as this tutorial (http://world-editor-tutorials.thehelper.net/cat_usersubmit.php?view=27219) told me otherwise, and this is where I learned a lot of my warcraft memory leak cleaning. I gained a further understanding by studying C++ with how this works, but i didn't know of spaces being an issue or needed

ex

call RemoveLocation(udg_tmp_point)

vs

call RemoveLocation ( udg_tmp_point )
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Those whitespaces would take space though.

Anyway, to make sure you don't get leaks, you have to make sure to: a) Destroy or Remove objects after using them and they no longer have any purpose and b) make all variables point to null after destroying it's contents, *or you can just overwrite it if you can.

Note: mostly applied to global variables, since it is vital for local variables to be pointed to null when a the function utilizing it is exited.
 

EdgeOfChaos

E

EdgeOfChaos

1: Totally unrelated to leaks
2: Doesn't take space after map is optimized as whitespace is removed.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
White spaces (that are not required by the syntax) contain information and as such increase map size. They do not alter the functional behaviour of the script in any way. Again it is important to note that only some white space counts as this, other white space is part of the syntax and so cannot be omitted if the script is to be parsed.

Here are some examples...

Necessary white space.
JASS:
function f takes nothing returns boolean
set x=1
call something(somethingelse)
return true

Unnecessary white space.
JASS:
if     something     then //only 1 space needed, not lots, ignore spaces for comment
    return      //both before and after comment and even in the comment is unnescescary
endif
set x = x + 1 //spaces between terms not required, ignore spaces for comment

White spaces can mostly be ignored. It is much better to produce readable and maintainable script and let an optimizer reduce the white spaces for publishing than to create a mess to save the odd byte here and there.
 
Status
Not open for further replies.
Top