Patchwork [4/5] Remove memory leaks, add one more assert.

login
register
mail settings
Submitter Sebastian Pop
Date May 24, 2011, 6:51 p.m.
Message ID <1306263072-5821-5-git-send-email-sebpop@gmail.com>
Download mbox | patch
Permalink /patch/97201/
State New
Headers show

Comments

Sebastian Pop - May 24, 2011, 6:51 p.m.
2011-05-24  Sebastian Pop  <sebastian.pop@amd.com>

	* graphite-dependences.c (graphite_outer_subscript_bound): Remove
	memory leaks, add one more assert.
---
 gcc/ChangeLog.graphite     |    5 +++++
 gcc/graphite-dependences.c |   21 +++++++++++++--------
 2 files changed, 18 insertions(+), 8 deletions(-)

Patch

diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite
index afcac69..9f71fe8 100644
--- a/gcc/ChangeLog.graphite
+++ b/gcc/ChangeLog.graphite
@@ -1,5 +1,10 @@ 
 2011-05-24  Sebastian Pop  <sebastian.pop@amd.com>
 
+	* graphite-dependences.c (graphite_outer_subscript_bound): Remove
+	memory leaks, add one more assert.
+
+2011-05-24  Sebastian Pop  <sebastian.pop@amd.com>
+
 	* graphite-dependences.c (build_alias_set_powerset): Remove
 	continue from loop, add one more assert.
 
diff --git a/gcc/graphite-dependences.c b/gcc/graphite-dependences.c
index cf68507..840c004 100644
--- a/gcc/graphite-dependences.c
+++ b/gcc/graphite-dependences.c
@@ -754,7 +754,7 @@  graphite_outer_subscript_bound (poly_dr_p pdr)
   graphite_dim_t gdim = scop_nb_params (scop);
 
   graphite_dim_t dim = tdim + dim1;
-
+  unsigned i, pos, sub1_dim = dim - sdim + 1 - gdim;
   ppl_Pointset_Powerset_C_Polyhedron_t isc, idr, res;
 
   combine_context_id_scat (&isc, pbb, false);
@@ -772,23 +772,28 @@  graphite_outer_subscript_bound (poly_dr_p pdr)
   {
     ppl_Linear_Expression_t le;
     ppl_Coefficient_t coef;
-    mpz_t v;
-    unsigned i;
+    mpz_t one;
 
-    mpz_init (v);
-    mpz_set_si (v, 1);
+    mpz_init (one);
+    mpz_set_si (one, 1);
     ppl_new_Coefficient (&coef);
-    ppl_assign_Coefficient_from_mpz_t (coef, v);
+    ppl_assign_Coefficient_from_mpz_t (coef, one);
 
     ppl_new_Linear_Expression_with_dimension (&le, dim);
 
-    for (i = 0; i < dim - sdim + 1 - gdim; i++)
+    for (i = 0; i < sub1_dim; i++)
       ppl_Pointset_Powerset_C_Polyhedron_affine_image (res, i, le, coef);
+
+    ppl_delete_Linear_Expression (le);
+    ppl_delete_Coefficient (coef);
+    mpz_clear (one);
   }
 
   {
     ppl_dimension_type *ds = XNEWVEC (ppl_dimension_type, dim - gdim - 1);
-    unsigned i, pos, sub1_dim = dim - sdim + 1 - gdim;
+
+    gcc_assert (sub1_dim < dim - gdim);
+
     for (i = 0, pos = 0; i < dim - gdim; i++)
       if (i != sub1_dim)
 	ds[pos++] = i;