From 1eba63835ea23cbae6059c076db985a47e39ce24 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 12 Nov 2016 11:48:48 -0700 Subject: Change type of encoding argument to gdbpy_extract_lazy_string This changes gdbpy_extract_lazy_string's "encoding" argument to be a unique_xmalloc_ptr. I chose this rather than std::string because it can sometimes be NULL. 2017-01-10 Tom Tromey * python/py-prettyprint.c (print_string_repr, print_children): Update. * python/py-lazy-string.c (gdbpy_extract_lazy_string): Change type of "encoding". * varobj.c (varobj_value_get_print_value): Update. * python/python-internal.h (gdbpy_extract_lazy_string): Update. --- gdb/python/py-lazy-string.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gdb/python/py-lazy-string.c') diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index 14575bf..4af4566 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -180,14 +180,13 @@ gdbpy_is_lazy_string (PyObject *result) } /* Extract the parameters from the lazy string object STRING. - ENCODING will either be set to NULL, or will be allocated with - xmalloc, in which case the callers is responsible for freeing - it. */ + ENCODING may be set to NULL, if no encoding is found. */ void gdbpy_extract_lazy_string (PyObject *string, CORE_ADDR *addr, struct type **str_type, - long *length, char **encoding) + long *length, + gdb::unique_xmalloc_ptr *encoding) { lazy_string_object *lazy; @@ -198,7 +197,7 @@ gdbpy_extract_lazy_string (PyObject *string, CORE_ADDR *addr, *addr = lazy->address; *str_type = lazy->type; *length = lazy->length; - *encoding = lazy->encoding ? xstrdup (lazy->encoding) : NULL; + encoding->reset (lazy->encoding ? xstrdup (lazy->encoding) : NULL); } -- cgit v1.1