diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2007-10-05 09:53:36 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2007-10-05 15:25:47 +0100 |
commit | f3d921baca02af4db5f8f1743f32e800d2f492bc (patch) | |
tree | 8dcb2469717a6ce39348356cd4fb1d48346eb61c /src/cairo-scaled-font.c | |
parent | 41aab58f3ae044f1baf668363376532381270ff4 (diff) |
[cairo-scaled-font] Destroy the zombie font.
If we do not transfer the font to the holdovers array (because it has
been removed from the cache and left in a zombie state), destroy it.
Diffstat (limited to 'src/cairo-scaled-font.c')
-rw-r--r-- | src/cairo-scaled-font.c | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c index 9cbe7bbc..a1568a3a 100644 --- a/src/cairo-scaled-font.c +++ b/src/cairo-scaled-font.c @@ -733,29 +733,31 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font) assert (CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&scaled_font->ref_count)); - if (_cairo_reference_count_dec_and_test (&scaled_font->ref_count) - && scaled_font->hash_entry.hash != ZOMBIE) { - /* Rather than immediately destroying this object, we put it into - * the font_map->holdovers array in case it will get used again - * soon (and is why we must hold the lock over the atomic op on - * the reference count). To make room for it, we do actually - * destroy the least-recently-used holdover. - */ - if (font_map->num_holdovers == CAIRO_SCALED_FONT_MAX_HOLDOVERS) - { - lru = font_map->holdovers[0]; - assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&lru->ref_count)); - - _cairo_hash_table_remove (font_map->hash_table, &lru->hash_entry); - - font_map->num_holdovers--; - memmove (&font_map->holdovers[0], - &font_map->holdovers[1], - font_map->num_holdovers * sizeof (cairo_scaled_font_t*)); - } + if (_cairo_reference_count_dec_and_test (&scaled_font->ref_count)) { + if (scaled_font->hash_entry.hash != ZOMBIE) { + /* Rather than immediately destroying this object, we put it into + * the font_map->holdovers array in case it will get used again + * soon (and is why we must hold the lock over the atomic op on + * the reference count). To make room for it, we do actually + * destroy the least-recently-used holdover. + */ + if (font_map->num_holdovers == CAIRO_SCALED_FONT_MAX_HOLDOVERS) + { + lru = font_map->holdovers[0]; + assert (! CAIRO_REFERENCE_COUNT_HAS_REFERENCE (&lru->ref_count)); + + _cairo_hash_table_remove (font_map->hash_table, &lru->hash_entry); + + font_map->num_holdovers--; + memmove (&font_map->holdovers[0], + &font_map->holdovers[1], + font_map->num_holdovers * sizeof (cairo_scaled_font_t*)); + } - font_map->holdovers[font_map->num_holdovers] = scaled_font; - font_map->num_holdovers++; + font_map->holdovers[font_map->num_holdovers] = scaled_font; + font_map->num_holdovers++; + } else + lru = scaled_font; } _cairo_scaled_font_map_unlock (); |