[cairo-commit] cairo-perl ChangeLog, 1.73.2.2, 1.73.2.3 Cairo.xs, 1.21, 1.21.2.1 CairoFont.xs, 1.8, 1.8.6.1 CairoMatrix.xs, 1.7, 1.7.6.1 CairoSurface.xs, 1.20, 1.20.2.1

Torsten Schoenfeld commit at pdx.freedesktop.org
Sat Dec 29 06:03:55 PST 2007


Committed by: tsch

Update of /cvs/cairo/cairo-perl
In directory kemper:/tmp/cvs-serv30443

Modified Files:
      Tag: stable-1-04
	ChangeLog Cairo.xs CairoFont.xs CairoMatrix.xs CairoSurface.xs 
Log Message:
	* Cairo.xs
	* CairoFont.xs
	* CairoMatrix.xs
	* CairoSurface.xs: Use perl's New*/Safefree facilities instead of
	calloc/malloc/free as the latter aren't safe on some platforms,
	notably Win32.  Patch by T.J. Ferraro.


Index: ChangeLog
===================================================================
RCS file: /cvs/cairo/cairo-perl/ChangeLog,v
retrieving revision 1.73.2.2
retrieving revision 1.73.2.3
diff -u -d -r1.73.2.2 -r1.73.2.3
--- ChangeLog	20 Nov 2007 20:04:10 -0000	1.73.2.2
+++ ChangeLog	29 Dec 2007 14:03:52 -0000	1.73.2.3
@@ -1,3 +1,14 @@
+2007-12-29  Torsten Schoenfeld  <kaffeetisch at gmx.de>
+
+	Merge from HEAD:
+
+	* Cairo.xs
+	* CairoFont.xs
+	* CairoMatrix.xs
+	* CairoSurface.xs: Use perl's New*/Safefree facilities instead of
+	calloc/malloc/free as the latter aren't safe on some platforms,
+	notably Win32.  Patch by T.J. Ferraro.
+
 2007-11-20  Torsten Schoenfeld  <kaffeetisch at gmx.de>
 
 	* Cairo.pm

Index: Cairo.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/Cairo.xs,v
retrieving revision 1.21
retrieving revision 1.21.2.1
diff -u -d -r1.21 -r1.21.2.1
--- Cairo.xs	30 Sep 2007 12:54:31 -0000	1.21
+++ Cairo.xs	29 Dec 2007 14:03:52 -0000	1.21.2.1
@@ -40,11 +40,11 @@
 	char *child_isa_full;
 	AV *isa;
 
-	child_isa_full = malloc (strlen (child_package) + 5 + 1);
+	New (0, child_isa_full, strlen(child_package) + 5 + 1, char);
 	child_isa_full = strcpy (child_isa_full, child_package);
 	child_isa_full = strcat (child_isa_full, "::ISA");
 	isa = get_av (child_isa_full, TRUE); /* create on demand */
-	free (child_isa_full);
+	Safefree (child_isa_full);
 
 	av_push (isa, newSVpv (parent_package, 0));
 }
@@ -351,7 +351,7 @@
 	if (n == 0) {
 		pts = NULL;
 	} else {
-		pts = malloc (sizeof (double) * n);
+		New (0, pts, n, double);
 		if (!pts)
 			croak ("malloc failure for (%d) elements", n);
 		for (i = FIRST ; i < items ; i++)
@@ -361,7 +361,7 @@
 	cairo_set_dash (cr, pts, n, offset);
     CLEANUP:
 	if (pts)
-		free (pts);
+		Safefree (pts);
 
 void cairo_set_miter_limit (cairo_t * cr, double limit);
 
@@ -513,11 +513,11 @@
 	int num_glyphs, i;
     CODE:
 	num_glyphs = items - 1;
-	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	Newz (0, glyphs, num_glyphs, cairo_glyph_t);
 	for (i = 1; i < items; i++)
 		glyphs[i - 1] = *SvCairoGlyph (ST (i));
 	cairo_show_glyphs (cr, glyphs, num_glyphs);
-	free (glyphs);
+	Safefree (glyphs);
 
 cairo_font_face_t * cairo_get_font_face (cairo_t *cr);
 
@@ -551,12 +551,12 @@
 	int num_glyphs, i;
     CODE:
 	num_glyphs = items - 1;
-	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	Newz (0, glyphs, num_glyphs, cairo_glyph_t);
 	for (i = 1; i < items; i++)
 		glyphs[i - 1] = *SvCairoGlyph (ST (i));
 	cairo_glyph_extents (cr, glyphs, num_glyphs, &extents);
 	RETVAL = &extents;
-	free (glyphs);
+	Safefree (glyphs);
     OUTPUT:
 	RETVAL
 
@@ -569,11 +569,11 @@
 	int num_glyphs, i;
     CODE:
 	num_glyphs = items - 1;
-	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	Newz (0, glyphs, num_glyphs, cairo_glyph_t);
 	for (i = 1; i < items; i++)
 		glyphs[i - 1] = *SvCairoGlyph (ST (i));
 	cairo_glyph_path (cr, glyphs, num_glyphs);
-	free (glyphs);
+	Safefree (glyphs);
 
 cairo_operator_t cairo_get_operator (cairo_t *cr);
 
@@ -608,7 +608,7 @@
 	if (count == 0) {
 		dashes = NULL;
 	} else {
-		dashes = malloc (sizeof (double) * count);
+		New (0, dashes, count, double);
 		if (!dashes)
 			croak ("malloc failure for (%d) elements", count);
 	}
@@ -617,7 +617,7 @@
 	PUSHs (sv_2mortal (newSVnv (offset)));
 	for (i = 0; i < count; i++)
 		PUSHs (sv_2mortal (newSVnv (dashes[i])));
-	free (dashes);
+	Safefree (dashes);
 
 #endif
 

Index: CairoFont.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoFont.xs,v
retrieving revision 1.8
retrieving revision 1.8.6.1
diff -u -d -r1.8 -r1.8.6.1
--- CairoFont.xs	10 Aug 2006 17:34:40 -0000	1.8
+++ CairoFont.xs	29 Dec 2007 14:03:53 -0000	1.8.6.1
@@ -72,12 +72,12 @@
 	cairo_text_extents_t extents;
     CODE:
 	num_glyphs = items - 1;
-	glyphs = calloc (sizeof (cairo_glyph_t), num_glyphs);
+	Newz (0, glyphs, num_glyphs, cairo_glyph_t);
 	for (i = 1; i < items; i++)
 		glyphs[i - 1] = *SvCairoGlyph (ST (i));
 	cairo_scaled_font_glyph_extents (scaled_font, glyphs, num_glyphs, &extents);
 	RETVAL = &extents;
-	free (glyphs);
+	Safefree (glyphs);
     OUTPUT:
 	RETVAL
 

Index: CairoMatrix.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoMatrix.xs,v
retrieving revision 1.7
retrieving revision 1.7.6.1
diff -u -d -r1.7 -r1.7.6.1
--- CairoMatrix.xs	14 May 2006 13:43:10 -0000	1.7
+++ CairoMatrix.xs	29 Dec 2007 14:03:53 -0000	1.7.6.1
@@ -11,7 +11,8 @@
 cairo_matrix_t *
 cairo_perl_copy_matrix (cairo_matrix_t *src)
 {
-	cairo_matrix_t *dst = malloc (sizeof (cairo_matrix_t));
+	cairo_matrix_t *dst;
+	New (0, dst, 1, cairo_matrix_t);
 
 	dst->xx = src->xx;
 	dst->xy = src->xy;
@@ -101,4 +102,4 @@
 
 void DESTROY (cairo_matrix_t * matrix)
     CODE:
-	free (matrix);
+	Safefree (matrix);

Index: CairoSurface.xs
===================================================================
RCS file: /cvs/cairo/cairo-perl/CairoSurface.xs,v
retrieving revision 1.20
retrieving revision 1.20.2.1
diff -u -d -r1.20 -r1.20.2.1
--- CairoSurface.xs	30 Sep 2007 12:54:32 -0000	1.20
+++ CairoSurface.xs	29 Dec 2007 14:03:53 -0000	1.20.2.1
@@ -142,7 +142,7 @@
 {
 	CairoPerlCallback *callback;
 
-	callback = calloc (sizeof (CairoPerlCallback), 1);
+	Newz (0, callback, 1, CairoPerlCallback);
 
 	callback->func = newSVsv (func);
 	if (data)
@@ -161,7 +161,7 @@
 	SvREFCNT_dec (callback->func);
 	if (callback->data)
 		SvREFCNT_dec (callback->data);
-	free (callback);
+	Safefree (callback);
 }
 
 /* -------------------------------------------------------------------------- */



More information about the cairo-commit mailing list