aboutsummaryrefslogtreecommitdiff
path: root/gdb/guile/scm-string.c
diff options
context:
space:
mode:
authorPedro Alves <palves@redhat.com>2018-07-19 16:34:55 +0100
committerPedro Alves <palves@redhat.com>2018-07-19 16:34:55 +0100
commit4c6933327e2e30c97ea4e49dc6f7e0f48941fd6f (patch)
treec0d4b6ed65bed79680f9f452db4f5fb352233c31 /gdb/guile/scm-string.c
parent4581dc8297381651284e2f4a9f835eebcc6f2328 (diff)
downloadbinutils-4c6933327e2e30c97ea4e49dc6f7e0f48941fd6f.zip
binutils-4c6933327e2e30c97ea4e49dc6f7e0f48941fd6f.tar.gz
binutils-4c6933327e2e30c97ea4e49dc6f7e0f48941fd6f.tar.bz2
Eliminate remaining gdb/guile cleanups
The remaining gdb/guile cleanups all handle the memory returned by gdbscm_scm_to_c_string. This commit makes gdbscm_scm_to_c_string return a gdb::unique_xmalloc_ptr instead of a naked pointer, and eliminates the remaining cleanups. gdb/ChangeLog: 2018-07-19 Pedro Alves <palves@redhat.com> * guile/guile-internal.h (gdbscm_scm_to_c_string): Now returns a gdb::unique_xmalloc_ptr. * guile/scm-breakpoint.c (gdbscm_set_breakpoint_condition_x): Adjust to use dbscm_wrap and gdb::unique_xmalloc_ptr. * guile/scm-exception.c (gdbscm_exception_message_to_string): Use copy-initialization. * guile/scm-pretty-print.c (ppscm_print_children): Use gdb::unique_xmalloc_ptr instead of cleanups. (gdbscm_apply_val_pretty_printer): Remove cleanups. * guile/scm-string.c (gdbscm_scm_to_c_string): Now returns a gdb::unique_xmalloc_ptr. * guile/scm-type.c (gdbscm_type_field, gdbscm_type_has_field_p): Adjust to use gdb::unique_xmalloc_ptr. * guile/scm-utils.c (extract_arg): Adjust. * guile/scm-value.c (gdbscm_value_field): Adjust to use gdb::unique_xmalloc_ptr instead of a cleanup.
Diffstat (limited to 'gdb/guile/scm-string.c')
-rw-r--r--gdb/guile/scm-string.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/gdb/guile/scm-string.c b/gdb/guile/scm-string.c
index 56e14c3..5779509 100644
--- a/gdb/guile/scm-string.c
+++ b/gdb/guile/scm-string.c
@@ -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. */