This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB 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] mfree() -> xmfree()


Finishing off stuff started long ago.

I think an obvious follow-up cleanup would be to reduce things like:

	if (blah != NULL)
	  xmfree (md, blah);

to

	xmfree (md, blah);

enjoy,
Andrew
2001-12-02  Andrew Cagney  <ac131313@redhat.com>

	* coffread.c, dbxread.c, elfread.c, hp-psymtab-read.c, hpread.c,
	nlmread.c, objfiles.c, os9kread.c, somread.c, source.c, symfile.c,
	symmisc.c, xcoffread.c: Use xmfree instead of mfree.

Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.20
diff -p -r1.20 coffread.c
*** coffread.c	2001/09/20 03:03:39	1.20
--- coffread.c	2001/12/02 22:31:34
*************** coff_symfile_finish (struct objfile *obj
*** 713,719 ****
  {
    if (objfile->sym_private != NULL)
      {
!       mfree (objfile->md, objfile->sym_private);
      }
  
    /* Let stabs reader clean up */
--- 713,719 ----
  {
    if (objfile->sym_private != NULL)
      {
!       xmfree (objfile->md, objfile->sym_private);
      }
  
    /* Let stabs reader clean up */
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.27
diff -p -r1.27 dbxread.c
*** dbxread.c	2001/11/08 04:39:04	1.27
--- dbxread.c	2001/12/02 22:31:49
*************** dbx_symfile_finish (struct objfile *objf
*** 788,794 ****
  	    }
  	  xfree (hfiles);
  	}
!       mfree (objfile->md, objfile->sym_stab_info);
      }
    free_header_files ();
  }
--- 788,794 ----
  	    }
  	  xfree (hfiles);
  	}
!       xmfree (objfile->md, objfile->sym_stab_info);
      }
    free_header_files ();
  }
*************** find_corresponding_bincl_psymtab (char *
*** 1051,1057 ****
  static void
  free_bincl_list (struct objfile *objfile)
  {
!   mfree (objfile->md, (PTR) bincl_list);
    bincls_allocated = 0;
  }
  
--- 1051,1057 ----
  static void
  free_bincl_list (struct objfile *objfile)
  {
!   xmfree (objfile->md, (PTR) bincl_list);
    bincls_allocated = 0;
  }
  
Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.16
diff -p -r1.16 elfread.c
*** elfread.c	2001/05/29 10:45:10	1.16
--- elfread.c	2001/12/02 22:31:56
*************** free_elfinfo (PTR objp)
*** 678,684 ****
    while (ssi)
      {
        nssi = ssi->next;
!       mfree (objfile->md, ssi);
        ssi = nssi;
      }
  
--- 678,684 ----
    while (ssi)
      {
        nssi = ssi->next;
!       xmfree (objfile->md, ssi);
        ssi = nssi;
      }
  
*************** elf_symfile_finish (struct objfile *objf
*** 709,715 ****
  {
    if (objfile->sym_stab_info != NULL)
      {
!       mfree (objfile->md, objfile->sym_stab_info);
      }
  }
  
--- 709,715 ----
  {
    if (objfile->sym_stab_info != NULL)
      {
!       xmfree (objfile->md, objfile->sym_stab_info);
      }
  }
  
Index: hp-psymtab-read.c
===================================================================
RCS file: /cvs/src/src/gdb/hp-psymtab-read.c,v
retrieving revision 1.12
diff -p -r1.12 hp-psymtab-read.c
*** hp-psymtab-read.c	2001/10/24 02:53:48	1.12
--- hp-psymtab-read.c	2001/12/02 22:31:58
*************** hpread_symfile_finish (struct objfile *o
*** 2073,2079 ****
  {
    if (objfile->sym_private != NULL)
      {
!       mfree (objfile->md, objfile->sym_private);
      }
  }
  
--- 2073,2079 ----
  {
    if (objfile->sym_private != NULL)
      {
!       xmfree (objfile->md, objfile->sym_private);
      }
  }
  
Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.10
diff -p -r1.10 hpread.c
*** hpread.c	2001/11/06 23:38:14	1.10
--- hpread.c	2001/12/02 22:32:04
*************** hpread_symfile_finish (struct objfile *o
*** 625,631 ****
  {
    if (objfile->sym_private != NULL)
      {
!       mfree (objfile->md, objfile->sym_private);
      }
  }
  
--- 625,631 ----
  {
    if (objfile->sym_private != NULL)
      {
!       xmfree (objfile->md, objfile->sym_private);
      }
  }
  
Index: nlmread.c
===================================================================
RCS file: /cvs/src/src/gdb/nlmread.c,v
retrieving revision 1.8
diff -p -r1.8 nlmread.c
*** nlmread.c	2001/07/07 17:19:50	1.8
--- nlmread.c	2001/12/02 22:32:08
*************** nlm_symfile_finish (struct objfile *objf
*** 224,230 ****
  {
    if (objfile->sym_private != NULL)
      {
!       mfree (objfile->md, objfile->sym_private);
      }
  }
  
--- 224,230 ----
  {
    if (objfile->sym_private != NULL)
      {
!       xmfree (objfile->md, objfile->sym_private);
      }
  }
  
Index: objfiles.c
===================================================================
RCS file: /cvs/src/src/gdb/objfiles.c,v
retrieving revision 1.17
diff -p -r1.17 objfiles.c
*** objfiles.c	2001/10/12 23:51:28	1.17
--- objfiles.c	2001/12/02 22:32:12
*************** allocate_objfile (bfd *abfd, int flags)
*** 187,199 ****
  	      objfile->mmfd = fd;
  	      /* Update pointers to functions to *our* copies */
  	      obstack_chunkfun (&objfile->psymbol_cache.cache, xmmalloc);
! 	      obstack_freefun (&objfile->psymbol_cache.cache, mfree);
  	      obstack_chunkfun (&objfile->psymbol_obstack, xmmalloc);
! 	      obstack_freefun (&objfile->psymbol_obstack, mfree);
  	      obstack_chunkfun (&objfile->symbol_obstack, xmmalloc);
! 	      obstack_freefun (&objfile->symbol_obstack, mfree);
  	      obstack_chunkfun (&objfile->type_obstack, xmmalloc);
! 	      obstack_freefun (&objfile->type_obstack, mfree);
  	      /* If already in objfile list, unlink it. */
  	      unlink_objfile (objfile);
  	      /* Forget things specific to a particular gdb, may have changed. */
--- 187,199 ----
  	      objfile->mmfd = fd;
  	      /* Update pointers to functions to *our* copies */
  	      obstack_chunkfun (&objfile->psymbol_cache.cache, xmmalloc);
! 	      obstack_freefun (&objfile->psymbol_cache.cache, xmfree);
  	      obstack_chunkfun (&objfile->psymbol_obstack, xmmalloc);
! 	      obstack_freefun (&objfile->psymbol_obstack, xmfree);
  	      obstack_chunkfun (&objfile->symbol_obstack, xmmalloc);
! 	      obstack_freefun (&objfile->symbol_obstack, xmfree);
  	      obstack_chunkfun (&objfile->type_obstack, xmmalloc);
! 	      obstack_freefun (&objfile->type_obstack, xmfree);
  	      /* If already in objfile list, unlink it. */
  	      unlink_objfile (objfile);
  	      /* Forget things specific to a particular gdb, may have changed. */
*************** allocate_objfile (bfd *abfd, int flags)
*** 216,231 ****
  	      objfile->flags |= OBJF_MAPPED;
  	      mmalloc_setkey (objfile->md, 0, objfile);
  	      obstack_specify_allocation_with_arg (&objfile->psymbol_cache.cache,
! 						   0, 0, xmmalloc, mfree,
  						   objfile->md);
  	      obstack_specify_allocation_with_arg (&objfile->psymbol_obstack,
! 						   0, 0, xmmalloc, mfree,
  						   objfile->md);
  	      obstack_specify_allocation_with_arg (&objfile->symbol_obstack,
! 						   0, 0, xmmalloc, mfree,
  						   objfile->md);
  	      obstack_specify_allocation_with_arg (&objfile->type_obstack,
! 						   0, 0, xmmalloc, mfree,
  						   objfile->md);
  	    }
  	}
--- 216,231 ----
  	      objfile->flags |= OBJF_MAPPED;
  	      mmalloc_setkey (objfile->md, 0, objfile);
  	      obstack_specify_allocation_with_arg (&objfile->psymbol_cache.cache,
! 						   0, 0, xmmalloc, xmfree,
  						   objfile->md);
  	      obstack_specify_allocation_with_arg (&objfile->psymbol_obstack,
! 						   0, 0, xmmalloc, xmfree,
  						   objfile->md);
  	      obstack_specify_allocation_with_arg (&objfile->symbol_obstack,
! 						   0, 0, xmmalloc, xmfree,
  						   objfile->md);
  	      obstack_specify_allocation_with_arg (&objfile->type_obstack,
! 						   0, 0, xmmalloc, xmfree,
  						   objfile->md);
  	    }
  	}
*************** allocate_objfile (bfd *abfd, int flags)
*** 280,286 ****
    objfile->obfd = abfd;
    if (objfile->name != NULL)
      {
!       mfree (objfile->md, objfile->name);
      }
    if (abfd != NULL)
      {
--- 280,286 ----
    objfile->obfd = abfd;
    if (objfile->name != NULL)
      {
!       xmfree (objfile->md, objfile->name);
      }
    if (abfd != NULL)
      {
*************** free_objfile (struct objfile *objfile)
*** 440,448 ****
    clear_pc_function_cache ();
  
    /* The last thing we do is free the objfile struct itself for the
!      non-reusable case, or detach from the mapped file for the reusable
!      case.  Note that the mmalloc_detach or the mfree is the last thing
!      we can do with this objfile. */
  
  #if defined(USE_MMALLOC) && defined(HAVE_MMAP)
  
--- 440,448 ----
    clear_pc_function_cache ();
  
    /* The last thing we do is free the objfile struct itself for the
!      non-reusable case, or detach from the mapped file for the
!      reusable case.  Note that the mmalloc_detach or the xmfree() is
!      the last thing we can do with this objfile. */
  
  #if defined(USE_MMALLOC) && defined(HAVE_MMAP)
  
*************** free_objfile (struct objfile *objfile)
*** 467,484 ****
      {
        if (objfile->name != NULL)
  	{
! 	  mfree (objfile->md, objfile->name);
  	}
        if (objfile->global_psymbols.list)
! 	mfree (objfile->md, objfile->global_psymbols.list);
        if (objfile->static_psymbols.list)
! 	mfree (objfile->md, objfile->static_psymbols.list);
        /* Free the obstacks for non-reusable objfiles */
        free_bcache (&objfile->psymbol_cache);
        obstack_free (&objfile->psymbol_obstack, 0);
        obstack_free (&objfile->symbol_obstack, 0);
        obstack_free (&objfile->type_obstack, 0);
!       mfree (objfile->md, objfile);
        objfile = NULL;
      }
  }
--- 467,484 ----
      {
        if (objfile->name != NULL)
  	{
! 	  xmfree (objfile->md, objfile->name);
  	}
        if (objfile->global_psymbols.list)
! 	xmfree (objfile->md, objfile->global_psymbols.list);
        if (objfile->static_psymbols.list)
! 	xmfree (objfile->md, objfile->static_psymbols.list);
        /* Free the obstacks for non-reusable objfiles */
        free_bcache (&objfile->psymbol_cache);
        obstack_free (&objfile->psymbol_obstack, 0);
        obstack_free (&objfile->symbol_obstack, 0);
        obstack_free (&objfile->type_obstack, 0);
!       xmfree (objfile->md, objfile);
        objfile = NULL;
      }
  }
Index: os9kread.c
===================================================================
RCS file: /cvs/src/src/gdb/os9kread.c,v
retrieving revision 1.11
diff -p -r1.11 os9kread.c
*** os9kread.c	2001/11/06 23:38:14	1.11
--- os9kread.c	2001/12/02 22:32:16
*************** os9k_symfile_finish (struct objfile *obj
*** 415,421 ****
  {
    if (objfile->sym_stab_info != NULL)
      {
!       mfree (objfile->md, objfile->sym_stab_info);
      }
  /*
     free_header_files ();
--- 415,421 ----
  {
    if (objfile->sym_stab_info != NULL)
      {
!       xmfree (objfile->md, objfile->sym_stab_info);
      }
  /*
     free_header_files ();
Index: somread.c
===================================================================
RCS file: /cvs/src/src/gdb/somread.c,v
retrieving revision 1.11
diff -p -r1.11 somread.c
*** somread.c	2001/09/20 03:03:40	1.11
--- somread.c	2001/12/02 22:32:18
*************** som_symfile_finish (struct objfile *objf
*** 423,429 ****
  {
    if (objfile->sym_stab_info != NULL)
      {
!       mfree (objfile->md, objfile->sym_stab_info);
      }
    hpread_symfile_finish (objfile);
  }
--- 423,429 ----
  {
    if (objfile->sym_stab_info != NULL)
      {
!       xmfree (objfile->md, objfile->sym_stab_info);
      }
    hpread_symfile_finish (objfile);
  }
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.20
diff -p -r1.20 source.c
*** source.c	2001/07/17 06:41:47	1.20
--- source.c	2001/12/02 22:32:22
*************** forget_cached_source_info (void)
*** 241,252 ****
  	{
  	  if (s->line_charpos != NULL)
  	    {
! 	      mfree (objfile->md, s->line_charpos);
  	      s->line_charpos = NULL;
  	    }
  	  if (s->fullname != NULL)
  	    {
! 	      mfree (objfile->md, s->fullname);
  	      s->fullname = NULL;
  	    }
  	}
--- 241,252 ----
  	{
  	  if (s->line_charpos != NULL)
  	    {
! 	      xmfree (objfile->md, s->line_charpos);
  	      s->line_charpos = NULL;
  	    }
  	  if (s->fullname != NULL)
  	    {
! 	      xmfree (objfile->md, s->fullname);
  	      s->fullname = NULL;
  	    }
  	}
*************** open_source_file (struct symtab *s)
*** 682,688 ****
        if (result >= 0)
  	return result;
        /* Didn't work -- free old one, try again. */
!       mfree (s->objfile->md, s->fullname);
        s->fullname = NULL;
      }
  
--- 682,688 ----
        if (result >= 0)
  	return result;
        /* Didn't work -- free old one, try again. */
!       xmfree (s->objfile->md, s->fullname);
        s->fullname = NULL;
      }
  
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.43
diff -p -r1.43 symfile.c
*** symfile.c	2001/11/14 21:55:21	1.43
--- symfile.c	2001/12/02 22:32:29
*************** reread_symbols (void)
*** 1667,1677 ****
  	      /* FIXME: Do we have to free a whole linked list, or is this
  	         enough?  */
  	      if (objfile->global_psymbols.list)
! 		mfree (objfile->md, objfile->global_psymbols.list);
  	      memset (&objfile->global_psymbols, 0,
  		      sizeof (objfile->global_psymbols));
  	      if (objfile->static_psymbols.list)
! 		mfree (objfile->md, objfile->static_psymbols.list);
  	      memset (&objfile->static_psymbols, 0,
  		      sizeof (objfile->static_psymbols));
  
--- 1667,1677 ----
  	      /* FIXME: Do we have to free a whole linked list, or is this
  	         enough?  */
  	      if (objfile->global_psymbols.list)
! 		xmfree (objfile->md, objfile->global_psymbols.list);
  	      memset (&objfile->global_psymbols, 0,
  		      sizeof (objfile->global_psymbols));
  	      if (objfile->static_psymbols.list)
! 		xmfree (objfile->md, objfile->static_psymbols.list);
  	      memset (&objfile->static_psymbols, 0,
  		      sizeof (objfile->static_psymbols));
  
*************** init_psymbol_list (struct objfile *objfi
*** 2417,2427 ****
  
    if (objfile->global_psymbols.list)
      {
!       mfree (objfile->md, (PTR) objfile->global_psymbols.list);
      }
    if (objfile->static_psymbols.list)
      {
!       mfree (objfile->md, (PTR) objfile->static_psymbols.list);
      }
  
    /* Current best guess is that approximately a twentieth
--- 2417,2427 ----
  
    if (objfile->global_psymbols.list)
      {
!       xmfree (objfile->md, (PTR) objfile->global_psymbols.list);
      }
    if (objfile->static_psymbols.list)
      {
!       xmfree (objfile->md, (PTR) objfile->static_psymbols.list);
      }
  
    /* Current best guess is that approximately a twentieth
Index: symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.6
diff -p -r1.6 symmisc.c
*** symmisc.c	2001/10/12 23:51:29	1.6
--- symmisc.c	2001/12/02 22:32:29
*************** free_symtab_block (struct objfile *objfi
*** 89,98 ****
    n = BLOCK_NSYMS (b);
    for (i = 0; i < n; i++)
      {
!       mfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i)));
!       mfree (objfile->md, (PTR) BLOCK_SYM (b, i));
      }
!   mfree (objfile->md, (PTR) b);
  }
  
  /* Free all the storage associated with the struct symtab <- S.
--- 89,98 ----
    n = BLOCK_NSYMS (b);
    for (i = 0; i < n; i++)
      {
!       xmfree (objfile->md, SYMBOL_NAME (BLOCK_SYM (b, i)));
!       xmfree (objfile->md, (PTR) BLOCK_SYM (b, i));
      }
!   xmfree (objfile->md, (PTR) b);
  }
  
  /* Free all the storage associated with the struct symtab <- S.
*************** free_symtab (register struct symtab *s)
*** 126,132 ****
        for (i = 0; i < n; i++)
  	free_symtab_block (s->objfile, BLOCKVECTOR_BLOCK (bv, i));
        /* Free the blockvector itself.  */
!       mfree (s->objfile->md, (PTR) bv);
        /* Also free the linetable.  */
  
      case free_linetable:
--- 126,132 ----
        for (i = 0; i < n; i++)
  	free_symtab_block (s->objfile, BLOCKVECTOR_BLOCK (bv, i));
        /* Free the blockvector itself.  */
!       xmfree (s->objfile->md, (PTR) bv);
        /* Also free the linetable.  */
  
      case free_linetable:
*************** free_symtab (register struct symtab *s)
*** 134,155 ****
           or by some other symtab, except for our linetable.
           Free that now.  */
        if (LINETABLE (s))
! 	mfree (s->objfile->md, (PTR) LINETABLE (s));
        break;
      }
  
    /* If there is a single block of memory to free, free it.  */
    if (s->free_ptr != NULL)
!     mfree (s->objfile->md, s->free_ptr);
  
    /* Free source-related stuff */
    if (s->line_charpos != NULL)
!     mfree (s->objfile->md, (PTR) s->line_charpos);
    if (s->fullname != NULL)
!     mfree (s->objfile->md, s->fullname);
    if (s->debugformat != NULL)
!     mfree (s->objfile->md, s->debugformat);
!   mfree (s->objfile->md, (PTR) s);
  }
  
  void
--- 134,155 ----
           or by some other symtab, except for our linetable.
           Free that now.  */
        if (LINETABLE (s))
! 	xmfree (s->objfile->md, (PTR) LINETABLE (s));
        break;
      }
  
    /* If there is a single block of memory to free, free it.  */
    if (s->free_ptr != NULL)
!     xmfree (s->objfile->md, s->free_ptr);
  
    /* Free source-related stuff */
    if (s->line_charpos != NULL)
!     xmfree (s->objfile->md, (PTR) s->line_charpos);
    if (s->fullname != NULL)
!     xmfree (s->objfile->md, s->fullname);
    if (s->debugformat != NULL)
!     xmfree (s->objfile->md, s->debugformat);
!   xmfree (s->objfile->md, (PTR) s);
  }
  
  void
Index: xcoffread.c
===================================================================
RCS file: /cvs/src/src/gdb/xcoffread.c,v
retrieving revision 1.17
diff -p -r1.17 xcoffread.c
*** xcoffread.c	2001/10/02 02:39:48	1.17
--- xcoffread.c	2001/12/02 22:32:40
*************** xcoff_symfile_finish (struct objfile *ob
*** 1860,1866 ****
  {
    if (objfile->sym_private != NULL)
      {
!       mfree (objfile->md, objfile->sym_private);
      }
  
    /* Start with a fresh include table for the next objfile.  */
--- 1860,1866 ----
  {
    if (objfile->sym_private != NULL)
      {
!       xmfree (objfile->md, objfile->sym_private);
      }
  
    /* Start with a fresh include table for the next objfile.  */

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