From: Tom Tromey Date: Sat, 13 Jul 2019 18:03:07 +0000 (-0600) Subject: Make obstack_strdup inline X-Git-Tag: binutils-2_33~310 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f25102f7b100337923d2c81ecc12a64d428e98fe;p=external%2Fbinutils.git Make obstack_strdup inline This changes obstack_strdup to be an inline function. This seems better to me, considering how small it is; but also it follows what the code did before the previous patch. gdb/ChangeLog 2019-08-06 Tom Tromey * gdb_obstack.h (obstack_strdup): Define. * gdb_obstack.c (obstack_strdup): Don't define. --- diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 3974808..29ffa1e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2019-08-06 Tom Tromey + * gdb_obstack.h (obstack_strdup): Define. + * gdb_obstack.c (obstack_strdup): Don't define. + +2019-08-06 Tom Tromey + * xcoffread.c (SYMNAME_ALLOC, process_xcoff_symbol): Use obstack_strdup. * typeprint.c (typedef_hash_table::find_global_typedef): Use diff --git a/gdb/gdb_obstack.c b/gdb/gdb_obstack.c index 0bf4abb..0125712 100644 --- a/gdb/gdb_obstack.c +++ b/gdb/gdb_obstack.c @@ -45,13 +45,3 @@ obconcat (struct obstack *obstackp, ...) return (char *) obstack_finish (obstackp); } - -/* See gdb_obstack.h. */ - -char * -obstack_strdup (struct obstack *obstackp, const char *string) -{ - char *obstring = (char *) obstack_alloc (obstackp, strlen (string) + 1); - strcpy (obstring, string); - return obstring; -} diff --git a/gdb/gdb_obstack.h b/gdb/gdb_obstack.h index 143fcf7..829e2f9 100644 --- a/gdb/gdb_obstack.h +++ b/gdb/gdb_obstack.h @@ -89,7 +89,11 @@ extern char *obconcat (struct obstack *obstackp, ...) ATTRIBUTE_SENTINEL; /* Duplicate STRING, returning an equivalent string that's allocated on the obstack OBSTACKP. */ -extern char *obstack_strdup (struct obstack *obstackp, const char *string); +static inline char * +obstack_strdup (struct obstack *obstackp, const char *string) +{ + return (char *) obstack_copy0 (obstackp, string, strlen (string)); +} /* An obstack that frees itself on scope exit. */ struct auto_obstack : obstack