summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Canciani <ranma42@gmail.com>2011-06-15 15:27:21 +0200
committerAndrea Canciani <ranma42@gmail.com>2011-06-16 12:17:33 +0200
commita2cd83a98670b7dd03aeb41334d6e2fb030048af (patch)
tree8c9079eb76e319ecf5dba28b2e6a2264a2468769 /src
parenta06668fabef17daff5f8cea125b8b33ea7568a81 (diff)
toy-font-face: Do not assume hash != 0
The assumption that no font face will hash to 0 is not correct. Moreover, no special value is needed to mark fonts in error status, as they can simply be detected upon lookup and destruction.
Diffstat (limited to 'src')
-rw-r--r--src/cairo-toy-font-face.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index 4c690da5..b82d8b06 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -148,7 +148,6 @@ _cairo_toy_font_face_init_key (cairo_toy_font_face_t *key,
hash += ((unsigned long) slant) * 1607;
hash += ((unsigned long) weight) * 1451;
- assert (hash != 0);
key->base.hash_entry.hash = hash;
}
@@ -312,7 +311,6 @@ cairo_toy_font_face_create (const char *family,
/* remove the bad font from the hash table */
_cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
- font_face->base.hash_entry.hash = 0;
}
/* Otherwise create it and insert into hash table. */
@@ -366,7 +364,12 @@ _cairo_toy_font_face_destroy (void *abstract_face)
return;
}
- if (font_face->base.hash_entry.hash != 0)
+ /* Font faces in SUCCESS status are guaranteed to be in the
+ * hashtable. Font faces in an error status are removed from the
+ * hashtable if they are found during a lookup, thus they should
+ * only be removed if they are in the hashtable. */
+ if (likely (font_face->base.status == CAIRO_STATUS_SUCCESS) ||
+ _cairo_hash_table_lookup (hash_table, &font_face->base.hash_entry) == font_face)
_cairo_hash_table_remove (hash_table, &font_face->base.hash_entry);
_cairo_toy_font_face_hash_table_unlock ();