From: Andrew Cagney Date: Tue, 10 Aug 2004 19:37:47 +0000 (+0000) Subject: 2004-08-10 Andrew Cagney X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7936743b083af802de53a9483c450d917e991d46;p=binutils-gdb.git 2004-08-10 Andrew Cagney * 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. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 38d28279073..3f8f016ccb0 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,19 @@ +2004-08-10 Andrew Cagney + + * 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 * MAINTAINERS: Remove David Carlton from c++ testsuite diff --git a/gdb/coffread.c b/gdb/coffread.c index 821ca44f3bf..1c31d0f5455 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -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)); diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 8b1286fff72..2f7c23ad4e5 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -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. */ diff --git a/gdb/defs.h b/gdb/defs.h index 7ec9b1ec5cd..3e076e0636d 100644 --- a/gdb/defs.h +++ b/gdb/defs.h @@ -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); diff --git a/gdb/elfread.c b/gdb/elfread.c index b6abe083a6e..a9f4e177104 100644 --- a/gdb/elfread.c +++ b/gdb/elfread.c @@ -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); diff --git a/gdb/hpread.c b/gdb/hpread.c index 070147335b2..8370a7f325e 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -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 *)); diff --git a/gdb/source.c b/gdb/source.c index 8c6fec1121b..aff0542c0bf 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -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); diff --git a/gdb/symfile.c b/gdb/symfile.c index 38f6c01136b..f203ba07678 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -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 *))); } } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index c17bda4783d..6457d9c984e 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -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 { diff --git a/gdb/utils.c b/gdb/utils.c index aea58f04b01..3552b8d4559 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -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; diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 645bd4d2252..e92ab02453f 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -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