summaryrefslogtreecommitdiff
path: root/pango/fonts.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-10-24 04:50:09 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-10-24 04:50:09 +0000
commitb178da14dabd63937c3867f6d5cbb29f7a31d69f (patch)
treecd998c7bde03f495f0e5badd09cfcbd96f44c0f9 /pango/fonts.c
parent24b36e5df683f622cfe9e210716c06da8193f6f8 (diff)
downloadpango-b178da14dabd63937c3867f6d5cbb29f7a31d69f.tar.gz
Bug 471577 – GBoxed GType for PangoGlyphItem
2007-10-24 Behdad Esfahbod <behdad@gnome.org> Bug 471577 – GBoxed GType for PangoGlyphItem * pango/pango-glyph-item.h: * pango/pango-glyph-item.c: New public API: PANGO_TYPE_GLYPH_ITEM pango_glyph_item_copy() pango_glyph_item_get_type() * pango/pango-layout.c: New public API: pango_layout_iter_copy() * pango/fonts.c (pango_font_description_copy), (pango_font_description_copy_static), (pango_font_description_free), (pango_font_descriptions_free), (pango_font_metrics_ref), (pango_font_metrics_unref): * pango/glyphstring.c (pango_glyph_string_copy), (pango_glyph_string_free): * pango/pango-attributes.c (pango_attr_list_ref), (pango_attr_list_unref), (pango_attr_list_copy): * pango/pango-color.c (pango_color_copy), (pango_color_free): * pango/pango-item.c (pango_item_copy), (pango_item_free): * pango/pango-layout.c (pango_layout_line_ref), (pango_layout_line_unref), (pango_layout_iter_copy), (pango_layout_iter_free): * pango/pango-layout.h: * pango/pango-matrix.c (pango_matrix_copy), (pango_matrix_free): Update all copy/free functions to accept NULL as legitimate input. Previously all were g_return_[val_]if_fail()ing it. * pango/pango.def: * docs/pango-sections.txt: * docs/tmpl/glyphs.sgml: * docs/tmpl/layout.sgml: Update. svn path=/trunk/; revision=2457
Diffstat (limited to 'pango/fonts.c')
-rw-r--r--pango/fonts.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/pango/fonts.c b/pango/fonts.c
index 0979ba1a..88627636 100644
--- a/pango/fonts.c
+++ b/pango/fonts.c
@@ -657,19 +657,21 @@ pango_font_description_better_match (const PangoFontDescription *desc,
/**
* pango_font_description_copy:
- * @desc: a #PangoFontDescription
+ * @desc: a #PangoFontDescription, may be %NULL
*
* Make a copy of a #PangoFontDescription.
*
* Return value: the newly allocated #PangoFontDescription, which should
- * be freed with pango_font_description_free().
+ * be freed with pango_font_description_free(), or %NULL
+ * if @desc was %NULL.
**/
PangoFontDescription *
pango_font_description_copy (const PangoFontDescription *desc)
{
PangoFontDescription *result;
- g_return_val_if_fail (desc != NULL, NULL);
+ if (desc == NULL)
+ return NULL;
result = g_slice_new (PangoFontDescription);
@@ -686,7 +688,7 @@ pango_font_description_copy (const PangoFontDescription *desc)
/**
* pango_font_description_copy_static:
- * @desc: a #PangoFontDescription
+ * @desc: a #PangoFontDescription, may be %NULL
*
* Like pango_font_description_copy(), but only a shallow copy is made
* of the family name and other allocated fields. The result can only
@@ -694,14 +696,16 @@ pango_font_description_copy (const PangoFontDescription *desc)
* when the copy is only needed temporarily.
*
* Return value: the newly allocated #PangoFontDescription, which should
- * be freed with pango_font_description_free().
+ * be freed with pango_font_description_free(), or %NULL
+ * if @desc was %NULL.
**/
PangoFontDescription *
pango_font_description_copy_static (const PangoFontDescription *desc)
{
PangoFontDescription *result;
- g_return_val_if_fail (desc != NULL, NULL);
+ if (desc == NULL)
+ return NULL;
result = g_slice_new (PangoFontDescription);
@@ -794,25 +798,25 @@ pango_font_description_hash (const PangoFontDescription *desc)
/**
* pango_font_description_free:
- * @desc: a #PangoFontDescription, or %NULL
+ * @desc: a #PangoFontDescription, may be %NULL
*
* Frees a font description.
**/
void
pango_font_description_free (PangoFontDescription *desc)
{
- if (desc)
- {
- if (desc->family_name && !desc->static_family)
- g_free (desc->family_name);
+ if (desc == NULL)
+ return;
- g_slice_free (PangoFontDescription, desc);
- }
+ if (desc->family_name && !desc->static_family)
+ g_free (desc->family_name);
+
+ g_slice_free (PangoFontDescription, desc);
}
/**
* pango_font_descriptions_free:
- * @descs: a pointer to an array of #PangoFontDescription, or %NULL
+ * @descs: a pointer to an array of #PangoFontDescription, may be %NULL
* @n_descs: number of font descriptions in @descs
*
* Frees a list of font descriptions from pango_font_map_list_fonts()
@@ -823,12 +827,12 @@ pango_font_descriptions_free (PangoFontDescription **descs,
{
int i;
- if (descs)
- {
- for (i = 0; i<n_descs; i++)
- pango_font_description_free (descs[i]);
- g_free (descs);
- }
+ if (descs == NULL)
+ return;
+
+ for (i = 0; i<n_descs; i++)
+ pango_font_description_free (descs[i]);
+ g_free (descs);
}
typedef struct
@@ -1455,7 +1459,7 @@ pango_font_metrics_new (void)
/**
* pango_font_metrics_ref:
- * @metrics: a #PangoFontMetrics structure
+ * @metrics: a #PangoFontMetrics structure, may be %NULL
*
* Increase the reference count of a font metrics structure by one.
*
@@ -1464,7 +1468,7 @@ pango_font_metrics_new (void)
PangoFontMetrics *
pango_font_metrics_ref (PangoFontMetrics *metrics)
{
- if (!metrics)
+ if (metrics == NULL)
return NULL;
metrics->ref_count++;
@@ -1474,7 +1478,7 @@ pango_font_metrics_ref (PangoFontMetrics *metrics)
/**
* pango_font_metrics_unref:
- * @metrics: a #PangoFontMetrics structure
+ * @metrics: a #PangoFontMetrics structure, may be %NULL
*
* Decrease the reference count of a font metrics structure by one. If
* the result is zero, frees the structure and any associated
@@ -1483,8 +1487,9 @@ pango_font_metrics_ref (PangoFontMetrics *metrics)
void
pango_font_metrics_unref (PangoFontMetrics *metrics)
{
- if (!metrics)
+ if (metrics == NULL)
return;
+
g_return_if_fail (metrics->ref_count > 0 );
metrics->ref_count--;