diff options
author | Tom Tromey <tom@tromey.com> | 2018-05-26 23:34:02 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2018-07-17 13:21:48 -0600 |
commit | c6c6149af440c3032eb7d02c2852907c61aac470 (patch) | |
tree | c2f5e25dc0448ab794d148ccea81afd71fb0d248 /gdb/guile/scm-pretty-print.c | |
parent | a1a31cb8dce7d1bfa7878dc08c28af330ef2ed69 (diff) | |
download | gdb-c6c6149af440c3032eb7d02c2852907c61aac470.zip gdb-c6c6149af440c3032eb7d02c2852907c61aac470.tar.gz gdb-c6c6149af440c3032eb7d02c2852907c61aac470.tar.bz2 |
Return unique_xmalloc_ptr from gdbscm_scm_to_string
This changes gdbscm_scm_to_string to return a unique_xmalloc_ptr and
then fixes all the callers. This allows for the removal of some
cleanups.
gdb/ChangeLog
2018-07-17 Tom Tromey <tom@tromey.com>
* guile/scm-param.c (pascm_set_func, pascm_show_func)
(compute_enum_list, pascm_set_param_value_x)
(gdbscm_parameter_value): Update.
* guile/guile-internal.h (gdbscm_scm_to_string): Update.
(gdbscm_scm_to_host_string): Update.
* guile/scm-math.c (vlscm_convert_typed_value_from_scheme):
Update.
* guile/scm-cmd.c (cmdscm_add_completion): Update.
* guile/scm-pretty-print.c (ppscm_print_string_repr): Update.
* guile/scm-string.c (gdbscm_scm_to_string): Return
unique_xmalloc_ptr.
(gdbscm_scm_to_host_string): Likewise.
Diffstat (limited to 'gdb/guile/scm-pretty-print.c')
-rw-r--r-- | gdb/guile/scm-pretty-print.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/gdb/guile/scm-pretty-print.c b/gdb/guile/scm-pretty-print.c index eea524b..f406c1f 100644 --- a/gdb/guile/scm-pretty-print.c +++ b/gdb/guile/scm-pretty-print.c @@ -668,18 +668,16 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint, } else if (scm_is_string (str_scm)) { - struct cleanup *cleanup; size_t length; - char *string + gdb::unique_xmalloc_ptr<char> string = gdbscm_scm_to_string (str_scm, &length, target_charset (gdbarch), 0 /*!strict*/, NULL); - cleanup = make_cleanup (xfree, string); if (hint == HINT_STRING) { struct type *type = builtin_type (gdbarch)->builtin_char; - LA_PRINT_STRING (stream, type, (gdb_byte *) string, + LA_PRINT_STRING (stream, type, (gdb_byte *) string.get (), length, NULL, 0, options); } else @@ -690,14 +688,13 @@ ppscm_print_string_repr (SCM printer, enum display_hint hint, for (i = 0; i < length; ++i) { - if (string[i] == '\0') + if (string.get ()[i] == '\0') fputs_filtered ("\\000", stream); else - fputc_filtered (string[i], stream); + fputc_filtered (string.get ()[i], stream); } } result = STRING_REPR_OK; - do_cleanups (cleanup); } else if (lsscm_is_lazy_string (str_scm)) { |