Replace xstrvprintf usages with string_vprintf
[deliverable/binutils-gdb.git] / gdb / guile / scm-string.c
index 56e14c3320ca20f15591f3b586f094f4648917ee..d09a54d80b4d29e5f43dce6bf7ae4e1a9f89610d 100644 (file)
@@ -48,13 +48,12 @@ gdbscm_scm_from_c_string (const char *string)
 
 /* Convert an SCM string to a C (latin1) string.
    "latin1" is chosen because Guile won't throw an exception.
-   Space for the result is allocated with malloc, caller must free.
    It is an error to call this if STRING is not a string.  */
 
-char *
+gdb::unique_xmalloc_ptr<char>
 gdbscm_scm_to_c_string (SCM string)
 {
-  return scm_to_latin1_string (string);
+  return gdb::unique_xmalloc_ptr<char> (scm_to_latin1_string (string));
 }
 
 /* Use printf to construct a Scheme string.  */
@@ -63,14 +62,12 @@ SCM
 gdbscm_scm_from_printf (const char *format, ...)
 {
   va_list args;
-  char *string;
   SCM result;
 
   va_start (args, format);
-  string = xstrvprintf (format, args);
+  std::string string = string_vprintf (format, args);
   va_end (args);
-  result = scm_from_latin1_string (string);
-  xfree (string);
+  result = scm_from_latin1_string (string.c_str ());
 
   return result;
 }
This page took 0.024577 seconds and 4 git commands to generate.