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 <tom@tromey.com>
* gdb_obstack.h (obstack_strdup): Define.
* gdb_obstack.c (obstack_strdup): Don't define.
+2019-08-06 Tom Tromey <tom@tromey.com>
+
+ * gdb_obstack.h (obstack_strdup): Define.
+ * gdb_obstack.c (obstack_strdup): Don't define.
+
2019-08-06 Tom Tromey <tom@tromey.com>
* xcoffread.c (SYMNAME_ALLOC, process_xcoff_symbol): Use
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;
-}
/* 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