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]

[obish] Eliminate xmmalloc


Hello,

Cleaning up the dregs of mmalloc.

For some time xmmalloc(ptr,...) has been calling malloc(...) (i.e., the PTR parameter is ignored). This replaces xmmalloc with xmalloc so that the PTR is ignored is clear.

committed,
Andrew
2004-08-10  Andrew Cagney  <cagney@gnu.org>

	* utils.c (xmmalloc): Delete.
	(xmalloc): Inline xmmalloc and mmalloc calls.
	(msavestring): Use xmalloc.
	* defs.h (xmmalloc): Delete declaration.
	* xcoffread.c (xcoff_symfile_init): Use xmalloc instead of
	xmmalloc.
	* symmisc.c (extend_psymbol_list): Ditto.
	* symfile.c (init_psymbol_list): Ditto.
	* source.c (find_source_lines): Ditto.
	* hpread.c (hpread_symfile_init, hpread_lookup_type): Ditto.
	* elfread.c (elf_symtab_read): Ditto.
	* dbxread.c (dbx_symfile_init, init_bincl_list): Ditto.
	* coffread.c (coff_symfile_init): Ditto.

Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.126
diff -p -u -r1.126 utils.c
--- utils.c	26 Jul 2004 14:53:05 -0000	1.126
+++ utils.c	10 Aug 2004 19:32:09 -0000
@@ -1037,33 +1037,6 @@ nomem (long size)
     }
 }
 
-/* The xmmalloc() family of memory management routines.
-
-   These are are like the mmalloc() family except that they implement
-   consistent semantics and guard against typical memory management
-   problems: if a malloc fails, an internal error is thrown; if
-   free(NULL) is called, it is ignored; if *alloc(0) is called, NULL
-   is returned.
-
-   All these routines are implemented using the mmalloc() family. */
-
-void *
-xmmalloc (void *md, size_t size)
-{
-  void *val;
-
-  /* See libiberty/xmalloc.c.  This function need's to match that's
-     semantics.  It never returns NULL.  */
-  if (size == 0)
-    size = 1;
-
-  val = mmalloc (md, size);
-  if (val == NULL)
-    nomem (size);
-
-  return (val);
-}
-
 void *
 xmrealloc (void *md, void *ptr, size_t size)
 {
@@ -1115,9 +1088,7 @@ xmfree (void *md, void *ptr)
 
    These are like the ISO-C malloc() family except that they implement
    consistent semantics and guard against typical memory management
-   problems.  See xmmalloc() above for further information.
-
-   All these routines are wrappers to the xmmalloc() family. */
+   problems.  */
 
 /* NOTE: These are declared using PTR to ensure consistency with
    "libiberty.h".  xfree() is GDB local.  */
@@ -1125,7 +1096,18 @@ xmfree (void *md, void *ptr)
 PTR				/* OK: PTR */
 xmalloc (size_t size)
 {
-  return xmmalloc (NULL, size);
+  void *val;
+
+  /* See libiberty/xmalloc.c.  This function need's to match that's
+     semantics.  It never returns NULL.  */
+  if (size == 0)
+    size = 1;
+
+  val = malloc (size);		/* OK: malloc */
+  if (val == NULL)
+    nomem (size);
+
+  return (val);
 }
 
 PTR				/* OK: PTR */
@@ -1230,7 +1212,7 @@ savestring (const char *ptr, size_t size
 char *
 msavestring (void *md, const char *ptr, size_t size)
 {
-  char *p = (char *) xmmalloc (md, size + 1);
+  char *p = (char *) xmalloc (size + 1);
   memcpy (p, ptr, size);
   p[size] = 0;
   return p;
Index: coffread.c
===================================================================
RCS file: /cvs/src/src/gdb/coffread.c,v
retrieving revision 1.56
diff -p -u -r1.56 coffread.c
--- coffread.c	10 Jun 2004 15:52:04 -0000	1.56
+++ coffread.c	10 Aug 2004 19:32:08 -0000
@@ -437,14 +437,13 @@ coff_symfile_init (struct objfile *objfi
 {
   /* Allocate struct to keep track of stab reading. */
   objfile->sym_stab_info = (struct dbx_symfile_info *)
-    xmmalloc (objfile->md, sizeof (struct dbx_symfile_info));
+    xmalloc (sizeof (struct dbx_symfile_info));
 
   memset (objfile->sym_stab_info, 0,
 	  sizeof (struct dbx_symfile_info));
 
   /* Allocate struct to keep track of the symfile */
-  objfile->sym_private = xmmalloc (objfile->md,
-				   sizeof (struct coff_symfile_info));
+  objfile->sym_private = xmalloc (sizeof (struct coff_symfile_info));
 
   memset (objfile->sym_private, 0, sizeof (struct coff_symfile_info));
 
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.69
diff -p -u -r1.69 dbxread.c
--- dbxread.c	1 Jul 2004 20:25:53 -0000	1.69
+++ dbxread.c	10 Aug 2004 19:32:08 -0000
@@ -625,7 +625,7 @@ dbx_symfile_init (struct objfile *objfil
 
   /* Allocate struct to keep track of the symfile */
   objfile->sym_stab_info = (struct dbx_symfile_info *)
-    xmmalloc (objfile->md, sizeof (struct dbx_symfile_info));
+    xmalloc (sizeof (struct dbx_symfile_info));
   memset (objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
 
   DBX_TEXT_SECTION (objfile) = bfd_get_section_by_name (sym_bfd, ".text");
@@ -892,7 +892,7 @@ init_bincl_list (int number, struct objf
 {
   bincls_allocated = number;
   next_bincl = bincl_list = (struct header_file_location *)
-    xmmalloc (objfile->md, bincls_allocated * sizeof (struct header_file_location));
+    xmalloc (bincls_allocated * sizeof (struct header_file_location));
 }
 
 /* Add a bincl to the list.  */
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.154
diff -p -u -r1.154 defs.h
--- defs.h	30 Jul 2004 19:17:19 -0000	1.154
+++ defs.h	10 Aug 2004 19:32:09 -0000
@@ -875,7 +875,6 @@ extern char *mstrsave (void *, const cha
 
 /* Robust versions of same.  Throw an internal error when no memory,
    guard against stray NULL arguments. */
-extern void *xmmalloc (void *md, size_t size);
 extern void *xmrealloc (void *md, void *ptr, size_t size);
 extern void *xmcalloc (void *md, size_t number, size_t size);
 extern void xmfree (void *md, void *ptr);
Index: elfread.c
===================================================================
RCS file: /cvs/src/src/gdb/elfread.c,v
retrieving revision 1.44
diff -p -u -r1.44 elfread.c
--- elfread.c	15 Jun 2004 01:04:19 -0000	1.44
+++ elfread.c	10 Aug 2004 19:32:09 -0000
@@ -377,7 +377,7 @@ elf_symtab_read (struct objfile *objfile
 				      + (sizeof (CORE_ADDR)
 					 * max_index));
 			      sectinfo = (struct stab_section_info *)
-				xmmalloc (objfile->md, size);
+				xmalloc (size);
 			      memset (sectinfo, 0, size);
 			      sectinfo->num_sections = max_index;
 			      if (filesym == NULL)
@@ -499,7 +499,7 @@ elf_symfile_read (struct objfile *objfil
 
   /* Allocate struct to keep track of the symfile */
   objfile->sym_stab_info = (struct dbx_symfile_info *)
-    xmmalloc (objfile->md, sizeof (struct dbx_symfile_info));
+    xmalloc (sizeof (struct dbx_symfile_info));
   memset ((char *) objfile->sym_stab_info, 0, sizeof (struct dbx_symfile_info));
   make_cleanup (free_elfinfo, (void *) objfile);
 
Index: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.49
diff -p -u -r1.49 hpread.c
--- hpread.c	1 Jun 2004 22:39:23 -0000	1.49
+++ hpread.c	10 Aug 2004 19:32:09 -0000
@@ -1668,7 +1668,7 @@ hpread_symfile_init (struct objfile *obj
 
   /* Allocate struct to keep track of the symfile */
   objfile->sym_private =
-    xmmalloc (objfile->md, sizeof (struct hpread_symfile_info));
+    xmalloc (sizeof (struct hpread_symfile_info));
   memset (objfile->sym_private, 0, sizeof (struct hpread_symfile_info));
 
   /* We haven't read in any types yet.  */
@@ -3024,7 +3024,7 @@ hpread_lookup_type (dnttpointer hp_type,
 	    {
 	      DNTT_TYPE_VECTOR_LENGTH (objfile) = LNTT_SYMCOUNT (objfile) + GNTT_SYMCOUNT (objfile);
 	      DNTT_TYPE_VECTOR (objfile) = (struct type **)
-		xmmalloc (objfile->md, DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
+		xmalloc (DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *));
 	      memset (&DNTT_TYPE_VECTOR (objfile)[old_len], 0,
 		      (DNTT_TYPE_VECTOR_LENGTH (objfile) - old_len) *
 		      sizeof (struct type *));
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.54
diff -p -u -r1.54 source.c
--- source.c	30 Jul 2004 19:17:19 -0000	1.54
+++ source.c	10 Aug 2004 19:32:09 -0000
@@ -984,8 +984,7 @@ find_source_lines (struct symtab *s, int
   long mtime = 0;
   int size;
 
-  line_charpos = (int *) xmmalloc (s->objfile->md,
-				   lines_allocated * sizeof (int));
+  line_charpos = (int *) xmalloc (lines_allocated * sizeof (int));
   if (fstat (desc, &st) < 0)
     perror_with_name (s->filename);
 
Index: symfile.c
===================================================================
RCS file: /cvs/src/src/gdb/symfile.c,v
retrieving revision 1.138
diff -p -u -r1.138 symfile.c
--- symfile.c	10 Aug 2004 16:09:54 -0000	1.138
+++ symfile.c	10 Aug 2004 19:32:09 -0000
@@ -2708,15 +2708,15 @@ init_psymbol_list (struct objfile *objfi
     {
       objfile->global_psymbols.next =
 	objfile->global_psymbols.list = (struct partial_symbol **)
-	xmmalloc (objfile->md, (objfile->global_psymbols.size
-				* sizeof (struct partial_symbol *)));
+	xmalloc ((objfile->global_psymbols.size
+		  * sizeof (struct partial_symbol *)));
     }
   if (objfile->static_psymbols.size > 0)
     {
       objfile->static_psymbols.next =
 	objfile->static_psymbols.list = (struct partial_symbol **)
-	xmmalloc (objfile->md, (objfile->static_psymbols.size
-				* sizeof (struct partial_symbol *)));
+	xmalloc ((objfile->static_psymbols.size
+		  * sizeof (struct partial_symbol *)));
     }
 }
 
Index: symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.30
diff -p -u -r1.30 symmisc.c
--- symmisc.c	28 Feb 2004 18:04:37 -0000	1.30
+++ symmisc.c	10 Aug 2004 19:32:09 -0000
@@ -1232,7 +1232,7 @@ extend_psymbol_list (struct psymbol_allo
     {
       new_size = 255;
       listp->list = (struct partial_symbol **)
-	xmmalloc (objfile->md, new_size * sizeof (struct partial_symbol *));
+	xmalloc (new_size * sizeof (struct partial_symbol *));
     }
   else
     {
Index: xcoffread.c
===================================================================
RCS file: /cvs/src/src/gdb/xcoffread.c,v
retrieving revision 1.41
diff -p -u -r1.41 xcoffread.c
--- xcoffread.c	6 Aug 2004 20:47:25 -0000	1.41
+++ xcoffread.c	10 Aug 2004 19:32:12 -0000
@@ -1838,8 +1838,7 @@ static void
 xcoff_symfile_init (struct objfile *objfile)
 {
   /* Allocate struct to keep track of the symfile */
-  objfile->sym_private = xmmalloc (objfile->md,
-				   sizeof (struct coff_symfile_info));
+  objfile->sym_private = xmalloc (sizeof (struct coff_symfile_info));
 
   /* XCOFF objects may be reordered, so set OBJF_REORDERED.  If we
      find this causes a significant slowdown in gdb then we could

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