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.
This commit is contained in:
Andrew Cagney 2004-08-10 19:37:47 +00:00
parent 902f2ccb3d
commit 7936743b08
11 changed files with 45 additions and 51 deletions

View File

@ -1,3 +1,19 @@
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.
2004-08-10 David Carlton <carlton@bactrian.org>
* MAINTAINERS: Remove David Carlton from c++ testsuite

View File

@ -437,14 +437,13 @@ coff_symfile_init (struct objfile *objfile)
{
/* 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));

View File

@ -625,7 +625,7 @@ dbx_symfile_init (struct objfile *objfile)
/* 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 objfile *objfile)
{
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. */

View File

@ -875,7 +875,6 @@ extern char *mstrsave (void *, const char *);
/* 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);

View File

@ -377,7 +377,7 @@ elf_symtab_read (struct objfile *objfile, int dynamic)
+ (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 *objfile, int mainline)
/* 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);

View File

@ -1668,7 +1668,7 @@ hpread_symfile_init (struct objfile *objfile)
/* 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, struct objfile *objfile)
{
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 *));

View File

@ -984,8 +984,7 @@ find_source_lines (struct symtab *s, int desc)
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);

View File

@ -2708,15 +2708,15 @@ init_psymbol_list (struct objfile *objfile, int total_symbols)
{
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 *)));
}
}

View File

@ -1232,7 +1232,7 @@ extend_psymbol_list (struct psymbol_allocation_list *listp,
{
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
{

View File

@ -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;

View File

@ -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