Make obstack_strdup inline
authorTom Tromey <tom@tromey.com>
Sat, 13 Jul 2019 18:03:07 +0000 (12:03 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 7 Aug 2019 02:08:48 +0000 (20:08 -0600)
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.

gdb/ChangeLog
gdb/gdb_obstack.c
gdb/gdb_obstack.h

index 3974808c0782d16c1b3a0c855d15ba03e0c5c000..29ffa1e96238837235109f41af4b926d894a0a46 100644 (file)
@@ -1,3 +1,8 @@
+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
index 0bf4abb82f6041a2d91333f15932af90b92f6074..01257120d076c51ff4459e6c53896c829eab2d23 100644 (file)
@@ -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;
-}
index 143fcf7179f5308b3d9273591ecdfffc92da96a3..829e2f959c41475d245fb46d1c911a2fae94a431 100644 (file)
@@ -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
This page took 0.03131 seconds and 4 git commands to generate.