[patch] tree-data-ref.c: Fix memory leak.

Kazu Hirata kazu@cs.umass.edu
Fri Dec 10 17:15:00 GMT 2004


Hi,

Attached is a patch to fix memory leak.

In free_data_refs, we free the VARRAY in each data_reference object,
but we somehow don't free the data_reference object itself.

Tested on i686-pc-linux-gnu.  OK to apply?

Kazu Hirata

2004-12-10  Kazu Hirata  <kazu@cs.umass.edu>

	* tree-data-ref.c (free_data_refs): Free each data_reference
	object.

Index: tree-data-ref.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/tree-data-ref.c,v
retrieving revision 2.17
diff -C4 -d -p -r2.17 tree-data-ref.c
*** tree-data-ref.c	12 Nov 2004 00:13:06 -0000	2.17
--- tree-data-ref.c	10 Dec 2004 15:22:35 -0000
*************** free_data_refs (varray_type datarefs)
*** 2478,2487 ****
    for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
      {
        struct data_reference *dr = (struct data_reference *) 
  	VARRAY_GENERIC_PTR (datarefs, i);
!       if (dr && DR_ACCESS_FNS (dr))
! 	varray_clear (DR_ACCESS_FNS (dr));
      }
    varray_clear (datarefs);
  }
  
--- 2478,2491 ----
    for (i = 0; i < VARRAY_ACTIVE_SIZE (datarefs); i++)
      {
        struct data_reference *dr = (struct data_reference *) 
  	VARRAY_GENERIC_PTR (datarefs, i);
!       if (dr)
! 	{
! 	  if (DR_ACCESS_FNS (dr))
! 	    varray_clear (DR_ACCESS_FNS (dr));
! 	  free (dr);
! 	}
      }
    varray_clear (datarefs);
  }
  



More information about the Gcc-patches mailing list