From 22185716cb29823a7c686d83e81aff0afafae86a Mon Sep 17 00:00:00 2001 From: cagney Date: Tue, 10 Aug 2004 20:03:27 +0000 Subject: [PATCH] 2004-08-10 Andrew Cagney * defs.h (xmrealloc): Delete. * utils.c (xmrealloc): Delete. (xrealloc): Inline calls to xmrealloc, mmalloc and mrealloc. * symmisc.c (extend_psymbol_list): Use xrealloc. * source.c (find_source_lines): Ditto. * hpread.c (hpread_lookup_type): Ditto. * dbxread.c (add_bincl_to_list): Ditto. --- gdb/ChangeLog | 8 ++++++++ gdb/dbxread.c | 4 ++-- gdb/defs.h | 1 - gdb/hpread.c | 3 +-- gdb/source.c | 11 +++++------ gdb/symmisc.c | 4 ++-- gdb/utils.c | 36 +++++++++++++++--------------------- 7 files changed, 33 insertions(+), 34 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3f8f016ccb..ca4adb0282 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,13 @@ 2004-08-10 Andrew Cagney + * defs.h (xmrealloc): Delete. + * utils.c (xmrealloc): Delete. + (xrealloc): Inline calls to xmrealloc, mmalloc and mrealloc. + * symmisc.c (extend_psymbol_list): Use xrealloc. + * source.c (find_source_lines): Ditto. + * hpread.c (hpread_lookup_type): Ditto. + * dbxread.c (add_bincl_to_list): Ditto. + * utils.c (xmmalloc): Delete. (xmalloc): Inline xmmalloc and mmalloc calls. (msavestring): Use xmalloc. diff --git a/gdb/dbxread.c b/gdb/dbxread.c index 2f7c23ad4e..28b0d6bb9e 100644 --- a/gdb/dbxread.c +++ b/gdb/dbxread.c @@ -905,8 +905,8 @@ add_bincl_to_list (struct partial_symtab *pst, char *name, int instance) int offset = next_bincl - bincl_list; bincls_allocated *= 2; bincl_list = (struct header_file_location *) - xmrealloc (pst->objfile->md, (char *) bincl_list, - bincls_allocated * sizeof (struct header_file_location)); + xrealloc ((char *) bincl_list, + bincls_allocated * sizeof (struct header_file_location)); next_bincl = bincl_list + offset; } next_bincl->pst = pst; diff --git a/gdb/defs.h b/gdb/defs.h index 3e076e0636..4a193fe829 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 *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/hpread.c b/gdb/hpread.c index 8370a7f325..70070d8fe7 100644 --- a/gdb/hpread.c +++ b/gdb/hpread.c @@ -3042,8 +3042,7 @@ hpread_lookup_type (dnttpointer hp_type, struct objfile *objfile) if (size_changed) { DNTT_TYPE_VECTOR (objfile) = (struct type **) - xmrealloc (objfile->md, - (char *) DNTT_TYPE_VECTOR (objfile), + xrealloc ((char *) DNTT_TYPE_VECTOR (objfile), (DNTT_TYPE_VECTOR_LENGTH (objfile) * sizeof (struct type *))); memset (&DNTT_TYPE_VECTOR (objfile)[old_len], 0, diff --git a/gdb/source.c b/gdb/source.c index aff0542c0b..a55bd33aca 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -1014,8 +1014,8 @@ find_source_lines (struct symtab *s, int desc) { lines_allocated *= 2; line_charpos = - (int *) xmrealloc (s->objfile->md, (char *) line_charpos, - sizeof (int) * lines_allocated); + (int *) xrealloc ((char *) line_charpos, + sizeof (int) * lines_allocated); } line_charpos[nlines++] = lseek (desc, 0, SEEK_CUR); } @@ -1052,8 +1052,8 @@ find_source_lines (struct symtab *s, int desc) { lines_allocated *= 2; line_charpos = - (int *) xmrealloc (s->objfile->md, (char *) line_charpos, - sizeof (int) * lines_allocated); + (int *) xrealloc ((char *) line_charpos, + sizeof (int) * lines_allocated); } line_charpos[nlines++] = p - data; } @@ -1063,8 +1063,7 @@ find_source_lines (struct symtab *s, int desc) #endif /* lseek linear. */ s->nlines = nlines; s->line_charpos = - (int *) xmrealloc (s->objfile->md, (char *) line_charpos, - nlines * sizeof (int)); + (int *) xrealloc ((char *) line_charpos, nlines * sizeof (int)); } diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 6457d9c984..1d8cdc7f51 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -1238,8 +1238,8 @@ extend_psymbol_list (struct psymbol_allocation_list *listp, { new_size = listp->size * 2; listp->list = (struct partial_symbol **) - xmrealloc (objfile->md, (char *) listp->list, - new_size * sizeof (struct partial_symbol *)); + xrealloc ((char *) listp->list, + new_size * sizeof (struct partial_symbol *)); } /* Next assumes we only went one over. Should be good if program works correctly */ diff --git a/gdb/utils.c b/gdb/utils.c index 3552b8d455..af5821929d 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1038,26 +1038,6 @@ nomem (long size) } void * -xmrealloc (void *md, void *ptr, 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; - - if (ptr != NULL) - val = mrealloc (md, ptr, size); - else - val = mmalloc (md, size); - if (val == NULL) - nomem (size); - - return (val); -} - -void * xmcalloc (void *md, size_t number, size_t size) { void *mem; @@ -1113,7 +1093,21 @@ xmalloc (size_t size) PTR /* OK: PTR */ xrealloc (PTR ptr, size_t size) /* OK: PTR */ { - return xmrealloc (NULL, ptr, 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; + + if (ptr != NULL) + val = realloc (ptr, size); /* OK: realloc */ + else + val = malloc (size); /* OK: malloc */ + if (val == NULL) + nomem (size); + + return (val); } PTR /* OK: PTR */ -- 2.11.0