From 4c6933327e2e30c97ea4e49dc6f7e0f48941fd6f Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 19 Jul 2018 16:34:55 +0100 Subject: 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 * 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. --- gdb/guile/scm-value.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'gdb/guile/scm-value.c') diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 8d42d93..43f8001 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -619,20 +619,14 @@ gdbscm_value_field (SCM self, SCM field_scm) { scoped_value_mark free_values; - char *field = gdbscm_scm_to_c_string (field_scm); - - struct cleanup *cleanups = make_cleanup (xfree, field); + gdb::unique_xmalloc_ptr field = gdbscm_scm_to_c_string (field_scm); struct value *tmp = v_smob->value; - struct value *res_val = value_struct_elt (&tmp, NULL, field, NULL, + struct value *res_val = value_struct_elt (&tmp, NULL, field.get (), NULL, "struct/class/union"); - SCM result = vlscm_scm_from_value (res_val); - - do_cleanups (cleanups); - - return result; + return vlscm_scm_from_value (res_val); }); } -- cgit v1.1