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

Saving diffrent handles on the same memory cell

Status
Not open for further replies.
Level 10
Joined
May 24, 2016
Messages
339
So the question is I save some effect by StringHash on Hashtable, then
Code:
call DestroyEffect(LoadEffectHandle(Hash,GetHandleId(f),StringHash("RPT_Eff")))
set eff = AddSpecialEffect....
call SaveEffectHandle(Hash,GetHandleId(f),StringHash("RPT_Eff"))
I do this, so I wonder, should I remove a memory cell in Hash before saving a new effect on it?
 
Level 21
Joined
May 16, 2012
Messages
644
why are you using a string hash? why not use:

JASS:
call SaveEffectHandle(Hash, GetHandleId(f), 1, eff)

a handle is a pointer to a data structure, in your case the effect eff. When you call the DestroyEffect function the effect is destroyed in game and the pointer still have its value stored. When you save another effect in its position the pointer is now overwritten with the new value (it dosent mean that the effect has leaked, because you destroyed it). The important think that you need to do is to, at some point, flush the child hastable for the handle f, nullfying their values and cleaning any handle leak, like this:

JASS:
call FlushChildHashtable(Hash, GetHandleId(f))
 
Status
Not open for further replies.
Top