This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[obish] Eliminate xmrealloc
- From: Andrew Cagney <cagney at gnu dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Tue, 10 Aug 2004 16:03:08 -0400
- Subject: [obish] Eliminate xmrealloc
FYI,
Exactly the same situtation as for xmmalloc - xmrealloc was equivalent
to xrealloc. This replaces the former with the latter.
committed,
Andrew
2004-08-10 Andrew Cagney <cagney@gnu.org>
* 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.
Index: utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.127
diff -p -u -r1.127 utils.c
--- utils.c 10 Aug 2004 19:37:47 -0000 1.127
+++ utils.c 10 Aug 2004 20:01:06 -0000
@@ -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 */
Index: dbxread.c
===================================================================
RCS file: /cvs/src/src/gdb/dbxread.c,v
retrieving revision 1.70
diff -p -u -r1.70 dbxread.c
--- dbxread.c 10 Aug 2004 19:37:47 -0000 1.70
+++ dbxread.c 10 Aug 2004 20:01:06 -0000
@@ -905,8 +905,8 @@ add_bincl_to_list (struct partial_symtab
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;
Index: defs.h
===================================================================
RCS file: /cvs/src/src/gdb/defs.h,v
retrieving revision 1.155
diff -p -u -r1.155 defs.h
--- defs.h 10 Aug 2004 19:37:47 -0000 1.155
+++ defs.h 10 Aug 2004 20:01:06 -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 *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: hpread.c
===================================================================
RCS file: /cvs/src/src/gdb/hpread.c,v
retrieving revision 1.50
diff -p -u -r1.50 hpread.c
--- hpread.c 10 Aug 2004 19:37:47 -0000 1.50
+++ hpread.c 10 Aug 2004 20:01:06 -0000
@@ -3042,8 +3042,7 @@ hpread_lookup_type (dnttpointer hp_type,
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,
Index: source.c
===================================================================
RCS file: /cvs/src/src/gdb/source.c,v
retrieving revision 1.55
diff -p -u -r1.55 source.c
--- source.c 10 Aug 2004 19:37:47 -0000 1.55
+++ source.c 10 Aug 2004 20:01:06 -0000
@@ -1014,8 +1014,8 @@ find_source_lines (struct symtab *s, int
{
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
{
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
#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));
}
Index: symmisc.c
===================================================================
RCS file: /cvs/src/src/gdb/symmisc.c,v
retrieving revision 1.31
diff -p -u -r1.31 symmisc.c
--- symmisc.c 10 Aug 2004 19:37:47 -0000 1.31
+++ symmisc.c 10 Aug 2004 20:01:06 -0000
@@ -1238,8 +1238,8 @@ extend_psymbol_list (struct psymbol_allo
{
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 */