• 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.

[Solved] A simple question about hashtables.

Status
Not open for further replies.
When you save a location in a hashtable, it doesn't make a copy. It just "points" to it.

So if you want to free a location, simply load it and remove it as usual:
  • Set TempLoc = (Load <Key> of <Key> in MyHashtable)
  • Custom script: call RemoveLocation(udg_TempLoc)
TempLoc isn't set to a new location--it is set to the exact same location you saved using "Hashtable - Save Point...". So when you save the location in your hashtable, you should not remove it until you load it later.
 
Level 5
Joined
Jan 17, 2014
Messages
131
When you save a location in a hashtable, it doesn't make a copy. It just "points" to it.

So if you want to free a location, simply load it and remove it as usual:
  • Set TempLoc = (Load <Key> of <Key> in MyHashtable)
  • Custom script: call RemoveLocation(udg_TempLoc)
TempLoc isn't set to a new location--it is set to the exact same location you saved using "Hashtable - Save Point...". So when you save the location in your hashtable, you should not remove it until you load it later.

Thank you. +rep
 
Level 8
Joined
Oct 2, 2013
Messages
288
Found this very useful post 6 years later :D
Just to clarify with an example:
1. I set a location on a variable. ObjectiveLoc = Center of Region,
2. I save ObjectiveLoc into some Units in a Hashtable. The Key is the unit itself.
4. I order those units to attack-move to point -> Getting the point from the hashtable with themselves as the key (not from the variable).
5. I Clear All Child Hashtables of those Units in Hashtable.
6. I remove the location of the variable. Call RemoveLocation(udg_ObjectiveLoc).

This leaves me with 0 leaks, correct?
 
Found this very useful post 6 years later :D
Just to clarify with an example:
1. I set a location on a variable. ObjectiveLoc = Center of Region,
2. I save ObjectiveLoc into some Units in a Hashtable. The Key is the unit itself.
4. I order those units to attack-move to point -> Getting the point from the hashtable with themselves as the key (not from the variable).
5. I Clear All Child Hashtables of those Units in Hashtable.
6. I remove the location of the variable. Call RemoveLocation(udg_ObjectiveLoc).

This leaves me with 0 leaks, correct?
If it goes like you described, 0 leaks. But if 1. can run again before 6. (and you don't load ObjectiveLoc from hashtable before clear child-hashtables), you might remove the wrong loc.
 
Status
Not open for further replies.
Top