When should I call g_value_init
/g_value_reset
?
Currently, I'm using g_value_init
and g_value_reset
in all cases, but I want to know whether it could be sped up.
I know at least that:
- When using objects or boxed types, one definitely needs to call
g_value_reset
, because the GValue could have acquired a reference or duplicated in case of it being aGBoxed
. - When using elementary types like
guint
orgboolean
(without any memory management), theg_value_reset
call should theoretically be unnecessary, because no memory should be allocated them. I've even read the implementation, and it proves to be true. However, I am worried that the authors could introduce a change and start to allocate some memory (or just do some tracing) and then it would cause a memory leak.
That's all my current research. I would like to broaden it, possibly backed by official documentation references. Thanks in advance.