From b4be9fadea469e2c937c81a8f1d3243206f9bcfc Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 21 May 2018 12:35:59 -0600 Subject: Use unique_xmalloc_ptr for read_string This changes read_string's "buffer" out-parameter to be a unique_xmalloc_ptr, then updates the users. This allows for the removal of some cleanups. I chose unique_xmalloc_ptr rather than byte_vector here due to the way Guile unwinding seems to work. Tested by the buildbot. gdb/ChangeLog 2018-06-18 Tom Tromey * valprint.h (read_string): Update. * valprint.c (read_string): Change type of "buffer". (val_print_string): Update. * python/py-value.c (valpy_string): Update. * language.h (struct language_defn) : Change type of "buffer". (default_get_string, c_get_string): Update. * language.c (default_get_string): Change type of "buffer". * guile/scm-value.c (gdbscm_value_to_string): Update. * c-lang.c (c_get_string): Change type of "buffer". --- gdb/guile/scm-value.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gdb/guile/scm-value.c') diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 5a28d4d..fccddfe 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -1106,7 +1106,7 @@ gdbscm_value_to_string (SCM self, SCM rest) char *encoding = NULL; SCM errors = SCM_BOOL_F; int length = -1; - gdb_byte *buffer = NULL; + gdb::unique_xmalloc_ptr buffer; const char *la_encoding = NULL; struct type *char_type = NULL; SCM result; @@ -1163,9 +1163,10 @@ gdbscm_value_to_string (SCM self, SCM rest) scm_dynwind_begin ((scm_t_dynwind_flags) 0); gdbscm_dynwind_xfree (encoding); - gdbscm_dynwind_xfree (buffer); + gdb_byte *buffer_contents = buffer.release (); + gdbscm_dynwind_xfree (buffer_contents); - result = scm_from_stringn ((const char *) buffer, + result = scm_from_stringn ((const char *) buffer_contents, length * TYPE_LENGTH (char_type), (encoding != NULL && *encoding != '\0' ? encoding -- cgit v1.1