From: Barak Itkin Date: Sun, 27 May 2012 10:20:21 +0000 (+0300) Subject: Add missing calls to free results in the main program X-Git-Tag: p2tc-0.1.0~58 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a616d6ddccc029c24721c4f06d8dc4ad782c489e;p=poly2tri-c Add missing calls to free results in the main program --- diff --git a/bin/main.c b/bin/main.c index 221cb10..941fa1f 100755 --- a/bin/main.c +++ b/bin/main.c @@ -157,6 +157,23 @@ read_points_file (const gchar *path, g_print ("Read %d points and %d colors\n", countPts, countCls); } +void +free_read_results (P2tPointPtrArray *points, + GArray **colors) +{ + gint i; + + if (points != NULL) + { + for (i = 0; i < (*points)->len; i++) + p2t_point_free (point_index (*points, i)); + g_ptr_array_free (*points, TRUE); + } + + if (colors != NULL) + g_array_free (*colors, TRUE); +} + /* Calculate a "deterministic random" color for each point * based on its memory address. Since we know that least-significant bytes * of the point address will change more than the mor-important ones, we @@ -279,9 +296,7 @@ gint main (int argc, char *argv[]) p2tr_dt_free (dt); p2tr_cdt_free (rcdt); + free_read_results (&pts, &colors); - g_ptr_array_free (pts, TRUE); - g_array_free (colors, TRUE); - return 0; }