Imported Upstream version 7.9
[platform/upstream/gdb.git] / gdb / common / common-utils.c
index ad01ed6..2925dd5 100644 (file)
@@ -1,6 +1,6 @@
 /* Shared general utility routines for GDB, the GNU debugger.
 
-   Copyright (C) 1986, 1988-2012 Free Software Foundation, Inc.
+   Copyright (C) 1986-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
-#ifdef GDBSERVER
-#include "server.h"
-#else
-#include "defs.h"
-#endif
-
-#include "gdb_assert.h"
-
-#include <stdlib.h>
-#include <stdio.h>
+#include "common-defs.h"
 
 /* The xmalloc() (libiberty.h) family of memory management routines.
 
@@ -137,22 +128,6 @@ xstrvprintf (const char *format, va_list ap)
   return ret;
 }
 
-void
-xasprintf (char **ret, const char *format, ...)
-{
-  va_list args;
-
-  va_start (args, format);
-  (*ret) = xstrvprintf (format, args);
-  va_end (args);
-}
-
-void
-xvasprintf (char **ret, const char *format, va_list ap)
-{
-  (*ret) = xstrvprintf (format, ap);
-}
-
 int
 xsnprintf (char *str, size_t size, const char *format, ...)
 {
@@ -166,3 +141,13 @@ xsnprintf (char *str, size_t size, const char *format, ...)
 
   return ret;
 }
+
+char *
+savestring (const char *ptr, size_t len)
+{
+  char *p = (char *) xmalloc (len + 1);
+
+  memcpy (p, ptr, len);
+  p[len] = 0;
+  return p;
+}