• 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] Does "GetUnitRace" cause leak?

Status
Not open for further replies.
No, GetUnitRace does not leak. It actually just points to one of six predefined races:
JASS:
    constant race               RACE_HUMAN                      = ConvertRace(1)
    constant race               RACE_ORC                        = ConvertRace(2)
    constant race               RACE_UNDEAD                     = ConvertRace(3)
    constant race               RACE_NIGHTELF                   = ConvertRace(4)
    constant race               RACE_DEMON                      = ConvertRace(5)
    constant race               RACE_OTHER                      = ConvertRace(7)

Interestingly enough, Blizzard skipped over ConvertRace(6). Perhaps they had another race planned?

And no, you don't need to null "race". (1) Races are never destroyed (2) Races don't extend agent, so they aren't referenced counted and don't need nulling to recycle their handle ID (again, races aren't destroyed anyway, so this fact doesn't really matter).

You can null them if you'd like. Most people will null all non-primitive locals anyway because it is easier than determining which ones you have to null and which ones you don't. There isn't really any harm done in nulling a variable, after all. You just add an extra line of code.
 
Level 11
Joined
Oct 11, 2012
Messages
711
No, GetUnitRace does not leak. It actually just points to one of six predefined races:
JASS:
    constant race               RACE_HUMAN                      = ConvertRace(1)
    constant race               RACE_ORC                        = ConvertRace(2)
    constant race               RACE_UNDEAD                     = ConvertRace(3)
    constant race               RACE_NIGHTELF                   = ConvertRace(4)
    constant race               RACE_DEMON                      = ConvertRace(5)
    constant race               RACE_OTHER                      = ConvertRace(7)

Interestingly enough, Blizzard skipped over ConvertRace(6). Perhaps they had another race planned?

And no, you don't need to null "race". (1) Races are never destroyed (2) Races don't extend agent, so they aren't referenced counted and don't need nulling to recycle their handle ID (again, races aren't destroyed anyway, so this fact doesn't really matter).

You can null them if you'd like. Most people will null all non-primitive locals anyway because it is easier than determining which ones you have to null and which ones you don't. There isn't really any harm done in nulling a variable, after all. You just add an extra line of code.

Thanks a lot for the detailed answer, PnF. +Rep
 
Status
Not open for further replies.
Top