diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-02-06 13:50:10 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-02-06 13:50:10 +0000 |
commit | 522ce4d5b39e325471edf77cea9ad15ed98505af (patch) | |
tree | 1e7c3eba8911f6e795ba6f364caba8a1d21702a4 /pango | |
parent | 8c71138ba5500a3d1bf446357992e8f165101173 (diff) | |
download | pango-522ce4d5b39e325471edf77cea9ad15ed98505af.tar.gz |
If NULL is passed to _copy, return NULL with no warning. If NULL is passed
2006-02-06 Behdad Esfahbod <behdad@gnome.org>
* pango/pango-utils.c (pango_matrix_copy, pango_matrix_free): If
NULL is passed to _copy, return NULL with no warning. If NULL is
passed to _free, do nothing with no warning. Docs updated.
* examples/viewer-pangoxft.c (render_callback): Multiply x,y by
PANGO_SCALE, as pango_xft_render_layout takes coordinates in
Pango units weirdly enough.
* viewer-pangocairo.c (render_callback): Do cairo_translate, to
draw correct bounding boxes for x,y nonzero.
* examples/renderdemo.c (do_output): If context has an all-zero matrix
set, interpret it as backend does not support transformation, so
warn on --rotate, and do not try to rotate.
* examples/viewer-pangox.c (pangox_view_get_context): Set an all-zero
matrix on context, to negotiate that we don't support transformations.
Diffstat (limited to 'pango')
-rw-r--r-- | pango/pango-utils.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/pango/pango-utils.c b/pango/pango-utils.c index 38083f18..9c570230 100644 --- a/pango/pango-utils.c +++ b/pango/pango-utils.c @@ -945,37 +945,46 @@ pango_matrix_get_type (void) /** * pango_matrix_copy: - * @matrix: a #PangoMatrix + * @matrix: a #PangoMatrix, can be %NULL * * Copies a #PangoMatrix. * * Return value: the newly allocated #PangoMatrix, which should - * be freed with pango_matrix_free(). + * be freed with pango_matrix_free(), or %NULL if + * @matrix was %NULL. * * Since: 1.6 **/ PangoMatrix * pango_matrix_copy (const PangoMatrix *matrix) { - g_return_val_if_fail (matrix != NULL, NULL); + PangoMatrix *new_matrix; + + if (matrix) + { + new_matrix = g_slice_new (PangoMatrix); + *new_matrix = *matrix; + } + else + new_matrix = NULL; - return g_memdup (matrix, sizeof (PangoMatrix)); + return new_matrix; } /** * pango_matrix_free: - * @matrix: a #PangoMatrix + * @matrix: a #PangoMatrix, or %NULL * * Free a #PangoMatrix created with pango_matrix_copy(). + * Does nothing if @matrix is %NULL. * * Since: 1.6 **/ void pango_matrix_free (PangoMatrix *matrix) { - g_return_if_fail (matrix != NULL); - - g_free (matrix); + if (matrix) + g_slice_free (PangoMatrix, matrix); } /** |