[perl-Cairo] Cairo::Ft: Properly dereference the font face SV



commit 18ba1bb8fa11ab7f9333c09a443a2252beade529
Author: Torsten Schönfeld <kaffeetisch gmx de>
Date:   Sun May 16 15:41:38 2010 +0200

    Cairo::Ft: Properly dereference the font face SV
    
    Previously, we tried using Perl_sv_free directly as a
    cairo_destroy_func_t.  But that cannot work since, at least under
    PERL_IMPLICIT_CONTEXT, Perl_sv_free takes two arguments.  Use a custom
    destroy function instead.

 CairoFt.xs |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
---
diff --git a/CairoFt.xs b/CairoFt.xs
index a065b34..1ce8bd1 100644
--- a/CairoFt.xs
+++ b/CairoFt.xs
@@ -10,6 +10,12 @@
 
 static const cairo_user_data_key_t face_key;
 
+static void
+face_destroy (void *face)
+{
+	SvREFCNT_dec ((SV *) face);
+}
+
 MODULE = Cairo::Ft	PACKAGE = Cairo::FtFontFace PREFIX = cairo_ft_font_face_
 
 # cairo_font_face_t * cairo_ft_font_face_create_for_ft_face (FT_Face face, int load_flags);
@@ -28,10 +34,8 @@ cairo_ft_font_face_create (class, SV *face, int load_flags=0)
 	RETVAL = cairo_ft_font_face_create_for_ft_face (real_face, load_flags);
 	/* Keep the face SV (and thus the FT_Face) alive long enough */
 	SvREFCNT_inc (face);
-	status = cairo_font_face_set_user_data (
-			RETVAL,
-			&face_key,
-			face, (cairo_destroy_func_t) Perl_sv_free);
+	status = cairo_font_face_set_user_data (RETVAL, &face_key, face,
+	                                        face_destroy);
 	if (status) {
 		warn ("Couldn't install a user data handler, "
 		      "so an FT_Face will be leaked");



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]