- Joined
- Aug 4, 2006
- Messages
- 357
"All handle objects saved or removed from a hashtable are automatically reference-counted (with the exception of TextTag, Lightning, Image, Ubersplat, and FogState). This allows handle objects to be saved in the hashtable without risk of the object’s being prematurely memory freed. The reference counts are updated when an object is either added to, flushed, or overwritten in a hashtable." -Karune
Can someone please explain in detail what this means? From what I understand, if the hashtable is flushed, any handle that no longer has references will be destroyed using the appropriate function. For example,
this would not destroy the loc variable, but
this would destroy it automatically?
Also, I'm assuming you can make hashtables of struct instances since they are basically integers. However, this would mean a ton of potential leaks when flushing the hashtables. They do not reference count integers and do not know to call destroy(), right?
Can someone please explain in detail what this means? From what I understand, if the hashtable is flushed, any handle that no longer has references will be destroyed using the appropriate function. For example,
JASS:
local hashtable ht = InitHashtable()
local location loc = Location(23.0, 47.0)
call SaveLocationHandle(ht, 0, 0, loc)
call RemoveSavedHandle(ht, 0, 0)
JASS:
local hashtable ht = InitHashtable()
local location loc = Location(23.0, 47.0)
call SaveLocationHandle(ht, 0, 0, loc)
set loc = null
call RemoveSavedHandle(ht, 0, 0)
Also, I'm assuming you can make hashtables of struct instances since they are basically integers. However, this would mean a ton of potential leaks when flushing the hashtables. They do not reference count integers and do not know to call destroy(), right?