This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


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);
  }
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]