[pango] [cairotwisted] Plug leak



commit 434011df553c8d40c1e6508c9bdea4884e591f97
Author: Behdad Esfahbod <behdad behdad org>
Date:   Mon Mar 30 13:13:39 2009 -0400

    [cairotwisted] Plug leak
---
 examples/cairotwisted.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/examples/cairotwisted.c b/examples/cairotwisted.c
index 056377d..27b9fb0 100644
--- a/examples/cairotwisted.c
+++ b/examples/cairotwisted.c
@@ -211,6 +211,8 @@ typedef double parametrization_t;
 
 /* Compute parametrization info.  That is, for each part of the 
  * cairo path, tags it with its length.
+ *
+ * Free returned value with g_free().
  */
 static parametrization_t *
 parametrize_path (cairo_path_t *path)
@@ -219,7 +221,7 @@ parametrize_path (cairo_path_t *path)
   cairo_path_data_t *data, last_move_to, current_point;
   parametrization_t *parametrization;
 
-  parametrization = malloc (path->num_data * sizeof (parametrization[0]));
+  parametrization = g_malloc (path->num_data * sizeof (parametrization[0]));
 
   for (i=0; i < path->num_data; i += path->data[i].header.length) {
     data = &path->data[i];
@@ -454,6 +456,8 @@ map_path_onto (cairo_t *cr, cairo_path_t *path)
 		  (transform_point_func_t) point_on_path, &param);
 
   cairo_append_path (cr, current_path);
+
+  g_free (param.parametrization);
 }
 
 



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