Forums > Dev


Feb 02 2014 | 8:16 am

Hello !

if i would use OBJ_FLAG_MEMORY for "hashtab" . how i should manage freeing memory if for example im "overwriting" its key content ? do i need to delete associated object value of that key before assigning new one ? i just noticed that it costs a lot of cpu cycles . anyway …
would it be better to use OBJ_FLAG_DATA and use "chuck" method for particular key ? but how to … manage it all :/

void foo_float(t_foo *x, double n){

  ///// hashtab_delete(x->hash,_sym_float);	???

	t_atom *a = (t_atom*)sysmem_newptr(sizeof(t_atom));
	atom_setfloat(a, n) ;
 	hashtab_store(x->hash, _sym_float , (t_object *)a);

Feb 03 2014 | 11:05 pm

Quoting from the sdk documentation:

The difference between hashtab_store_safe() and hashtab_store() is what happens in the event of a collision in the hash table. The normal hashtab_store() function will free the existing value at the collision location with sysmem_freeptr() and then replaces it.

… actually, I suspect the text is not 100% accurate, as in the standard case the value should get freed with object_free() – iirc, I checked this out at some point. But with OBJ_FLAG_MEMORY things should be as described.


Feb 04 2014 | 1:49 am

Thank you for the clue Andrea !

Viewing 3 posts - 1 through 3 (of 3 total)

Forums > Dev