summaryrefslogtreecommitdiff
path: root/src/cairo-font.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cairo-font.c')
-rw-r--r--src/cairo-font.c45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/cairo-font.c b/src/cairo-font.c
index 3bd1e0318..0aeb00b61 100644
--- a/src/cairo-font.c
+++ b/src/cairo-font.c
@@ -53,15 +53,19 @@ _cairo_font_face_init (cairo_font_face_t *font_face,
/**
* cairo_font_face_reference:
- * @font_face: a #cairo_font_face_t
+ * @font_face: a #cairo_font_face_t, (may be NULL in which case this
+ * function does nothing).
*
* Increases the reference count on @font_face by one. This prevents
- * @font_face from being destroyed until a matching call to cairo_font_face_destroy()
- * is made.
+ * @font_face from being destroyed until a matching call to
+ * cairo_font_face_destroy() is made.
**/
void
cairo_font_face_reference (cairo_font_face_t *font_face)
{
+ if (font_face == NULL)
+ return;
+
font_face->refcount++;
}
@@ -76,6 +80,9 @@ cairo_font_face_reference (cairo_font_face_t *font_face)
void
cairo_font_face_destroy (cairo_font_face_t *font_face)
{
+ if (font_face == NULL)
+ return;
+
if (--(font_face->refcount) > 0)
return;
@@ -88,7 +95,7 @@ cairo_font_face_destroy (cairo_font_face_t *font_face)
if (font_face->refcount > 0)
return;
- _cairo_user_data_array_destroy (&font_face->user_data);
+ _cairo_user_data_array_fini (&font_face->user_data);
free (font_face);
}
@@ -327,6 +334,9 @@ _cairo_simple_font_face_destroy (void *abstract_face)
cairo_cache_t *cache;
cairo_simple_cache_key_t key;
+ if (simple_face == NULL)
+ return;
+
_lock_global_simple_cache ();
cache = _get_global_simple_cache ();
assert (cache);
@@ -395,7 +405,7 @@ _cairo_simple_font_face_create (const char *family,
return NULL;
}
status = _cairo_cache_lookup (cache, &key, (void **) &entry, &created_entry);
- if (CAIRO_OK (status) && !created_entry)
+ if (status == CAIRO_STATUS_SUCCESS && !created_entry)
cairo_font_face_reference (&entry->font_face->base);
_unlock_global_simple_cache ();
@@ -586,7 +596,7 @@ _cairo_outer_font_cache_create_entry (void *cache,
}
status = _cairo_cache_lookup (cache, key, (void **) &inner_entry, &created_entry);
- if (!CAIRO_OK (status)) {
+ if (status) {
free (entry);
return status;
}
@@ -636,7 +646,7 @@ _cairo_inner_font_cache_create_entry (void *cache,
k->font_matrix,
k->ctm,
&entry->scaled_font);
- if (!CAIRO_OK (status)) {
+ if (status) {
free (entry);
return status;
}
@@ -727,11 +737,11 @@ cairo_scaled_font_create (cairo_font_face_t *font_face,
}
status = _cairo_cache_lookup (cache, &key, (void **) &entry, NULL);
- if (CAIRO_OK (status))
+ if (status == CAIRO_STATUS_SUCCESS)
cairo_scaled_font_reference (entry->scaled_font);
_unlock_global_font_cache ();
- if (!CAIRO_OK (status))
+ if (status)
return NULL;
return entry->scaled_font;
@@ -847,12 +857,18 @@ _cairo_unscaled_font_init (cairo_unscaled_font_t *unscaled_font,
void
_cairo_unscaled_font_reference (cairo_unscaled_font_t *unscaled_font)
{
+ if (unscaled_font == NULL)
+ return;
+
unscaled_font->refcount++;
}
void
_cairo_unscaled_font_destroy (cairo_unscaled_font_t *unscaled_font)
{
+ if (unscaled_font == NULL)
+ return;
+
if (--(unscaled_font->refcount) > 0)
return;
@@ -867,7 +883,8 @@ _cairo_unscaled_font_destroy (cairo_unscaled_font_t *unscaled_font)
/**
* cairo_scaled_font_reference:
- * @scaled_font: a #cairo_scaled_font_t
+ * @scaled_font: a #cairo_scaled_font_t, (may be NULL in which case
+ * this function does nothing)
*
* Increases the reference count on @scaled_font by one. This prevents
* @scaled_font from being destroyed until a matching call to
@@ -876,6 +893,9 @@ _cairo_unscaled_font_destroy (cairo_unscaled_font_t *unscaled_font)
void
cairo_scaled_font_reference (cairo_scaled_font_t *scaled_font)
{
+ if (scaled_font == NULL)
+ return;
+
scaled_font->refcount++;
}
@@ -893,6 +913,9 @@ cairo_scaled_font_destroy (cairo_scaled_font_t *scaled_font)
cairo_font_cache_key_t key;
cairo_cache_t *cache;
+ if (scaled_font == NULL)
+ return;
+
if (--(scaled_font->refcount) > 0)
return;
@@ -935,7 +958,7 @@ cairo_scaled_font_extents (cairo_scaled_font_t *scaled_font,
status = _cairo_scaled_font_font_extents (scaled_font, extents);
- if (!CAIRO_OK (status))
+ if (status)
return status;
_cairo_matrix_compute_scale_factors (&scaled_font->font_matrix,