[cairo] deleting hash objects while iterating
Carl Worth
cworth at cworth.org
Mon Apr 10 17:38:57 PDT 2006
On Sun, 09 Apr 2006 00:59:52 -0700, Keith Packard wrote:
>
> It was also easy to fix; just prevent the table from being resized while
> iterating and clean it up after the iteration is completed.
>
> Is this a reasonable thing to do?
Looks good. Thanks for the fix.
Existing code for deleting all entries was rather painful[*]. So it
will be nice to replace that with something more straightforward and
more efficient now.
Since this is just used internally and only for iterating, I might
switch to a name of "iterating" rather than the less descriptive
"locked".
-Carl
[*] For example:
/* This is rather inefficient, but destroying the hash table
* is something we only do during debugging, (during
* cairo_debug_reset_static_data), when efficiency is not
* relevant. */
while (1) {
unscaled = _cairo_hash_table_random_entry (font_map->hash_table,
NULL);
if (unscaled == NULL)
break;
_cairo_hash_table_remove (font_map->hash_table,
&unscaled->base.hash_entry);
_font_map_release_face_lock_held (font_map, unscaled);
_cairo_ft_unscaled_font_fini (unscaled);
free (unscaled);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060410/e2729a54/attachment.pgp
More information about the cairo
mailing list