diff --git a/ChangeLog b/ChangeLog index 0e0850e9c..cbc042b4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,26 @@ the clip surface to a new surface the size of the intersection of the old clip surface and the extents of the new clip path. +2005-06-03 Carl Worth + + * src/cairo-font.c: (cairo_font_face_reference), + (cairo_font_face_destroy), (_cairo_simple_font_face_destroy), + (_cairo_unscaled_font_reference), (_cairo_unscaled_font_destroy), + (cairo_scaled_font_reference), (cairo_scaled_font_destroy): + * src/cairo-ft-font.c: (_ft_font_cache_destroy_cache), + (_cairo_ft_unscaled_font_destroy), (_ft_font_face_destroy): + * src/cairo-glitz-surface.c: (_cairo_glitz_area_destroy): + * src/cairo-path-data.c: (cairo_path_destroy): + * src/cairo-pdf-surface.c: (cairo_pdf_font_destroy), + (cairo_pdf_ft_font_destroy): + * src/cairo-win32-font.c: (_cairo_win32_scaled_font_destroy): + Allow NULL as a valid value for several objects. That is, calling + reference or destroy on these objects will simply do nothing, + successfully. + + * src/cairo-atsui-font.c: (_cairo_atsui_font_destroy_font): Remove + extra whitespace. + 2005-06-03 Carl Worth * src/cairoint.h: diff --git a/src/cairo-atsui-font.c b/src/cairo-atsui-font.c index 7460ca79f..5c7ddf54a 100644 --- a/src/cairo-atsui-font.c +++ b/src/cairo-atsui-font.c @@ -209,7 +209,6 @@ _cairo_atsui_font_destroy_font(void *abstract_font) { cairo_atsui_font_t *font = abstract_font; - if (font == NULL) return; diff --git a/src/cairo-font.c b/src/cairo-font.c index b40598f11..ec8463d6a 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; @@ -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); @@ -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; diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c index 67a7891ee..771844da5 100644 --- a/src/cairo-ft-font.c +++ b/src/cairo-ft-font.c @@ -256,6 +256,7 @@ static void _ft_font_cache_destroy_cache (void *cache) { ft_cache_t *fc = (ft_cache_t *) cache; + FT_Done_FreeType (fc->lib); free (fc); } @@ -482,6 +483,9 @@ _cairo_ft_unscaled_font_destroy (void *abstract_font) { ft_unscaled_font_t *unscaled = abstract_font; + if (unscaled == NULL) + return; + if (unscaled->from_face) { /* See comments in _ft_font_face_destroy about the "zombie" state * for a _ft_font_face. @@ -1340,6 +1344,9 @@ _ft_font_face_destroy (void *abstract_face) ft_font_face_t *tmp_face = NULL; ft_font_face_t *last_face = NULL; + if (font_face == NULL) + return; + /* When destroying the face created by cairo_ft_font_face_create_for_ft_face, * we have a special "zombie" state for the face when the unscaled font * is still alive but there are no public references to the font face. diff --git a/src/cairo-glitz-surface.c b/src/cairo-glitz-surface.c index 9104b8333..dbe669d80 100644 --- a/src/cairo-glitz-surface.c +++ b/src/cairo-glitz-surface.c @@ -1328,7 +1328,7 @@ _cairo_glitz_area_create (cairo_glitz_root_area_t *root, static void _cairo_glitz_area_destroy (cairo_glitz_area_t *area) { - if (!area) + if (area == NULL) return; if (area->state == CAIRO_GLITZ_AREA_OCCUPIED) diff --git a/src/cairo-path-data.c b/src/cairo-path-data.c index 93af8034f..37107dc24 100644 --- a/src/cairo-path-data.c +++ b/src/cairo-path-data.c @@ -364,9 +364,26 @@ _cairo_path_data_create_real (cairo_path_fixed_t *path_fixed, return path; } +/** + * cairo_path_destroy: + * @path: a #cairo_path_t pointer returned from either cairo_copy_path + * or cairo_copy_path_flat. + * + * Frees @path and all memory associated with it. Upon returning from + * this function @path will be pointing to an invalid location which + * should not be used. + * + * The cairo_path_destroy function should only be called with a + * pointer to a #cairo_path_t returned by a cairo function. Any + * manually created cairo_path_t object should be freed manually as + * well. + **/ void cairo_path_destroy (cairo_path_t *path) { + if (path == NULL) + return; + free (path->data); path->num_data = 0; free (path); diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c index f1c47edb1..17f968c75 100644 --- a/src/cairo-pdf-surface.c +++ b/src/cairo-pdf-surface.c @@ -291,6 +291,9 @@ cairo_pdf_font_generate (cairo_pdf_font_t *font, static void cairo_pdf_font_destroy (cairo_pdf_font_t *font) { + if (font == NULL) + return; + font->backend->destroy (font); } @@ -378,6 +381,9 @@ cairo_pdf_ft_font_destroy (void *abstract_font) { cairo_pdf_ft_font_t *font = abstract_font; + if (font == NULL) + return; + _cairo_unscaled_font_destroy (font->base.unscaled_font); free (font->base.base_font); free (font->parent_to_subset); diff --git a/src/cairo-win32-font.c b/src/cairo-win32-font.c index 4d540d7f5..34ecf78b0 100644 --- a/src/cairo-win32-font.c +++ b/src/cairo-win32-font.c @@ -466,6 +466,9 @@ _cairo_win32_scaled_font_destroy (void *abstract_font) { cairo_win32_scaled_font_t *scaled_font = abstract_font; + if (scaled_font == NULL) + return; + if (scaled_font->scaled_hfont) DeleteObject (scaled_font->scaled_hfont);