Re: [Tracker] Merging Turtle branch to Trunk



On Tue, 2008-12-09 at 18:42 +0100, JÃrg Billeter wrote:
On Tue, 2008-12-09 at 18:32 +0100, Philip Van Hoof wrote:
 
-   g_hash_table_insert (metadata->table,
-                        g_object_ref (field),
-                        data);
+   g_hash_table_replace (metadata->table,
+                         g_object_ref (field),
+                         data);
+

## If you don't use _replace here then the GHashTable wont exec the
## GDestroyNotify. This means that you always leak the reference
## per each time that you add a string to a list-element.

No, _insert will not leak. The only difference between _insert and
_replace when replacing an existing entry is that _insert will destroy
the supplied new key and _replace will destroy the old key that was
stored in the table. In this example, it probably doesn't matter at all.

Oh I see. No then it wont matter in this case, as it's reference based.

Only if the list is the key and not the value it might have mattered
then.


-- 
Philip Van Hoof, freelance software developer
home: me at pvanhoof dot be 
gnome: pvanhoof at gnome dot org 
http://pvanhoof.be/blog
http://codeminded.be




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]