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  <tom@tromey.com>

	* 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.
This commit is contained in:
Tom Tromey 2016-11-12 11:48:48 -07:00
parent bde7b3e3a0
commit 1eba63835e
5 changed files with 22 additions and 16 deletions

View file

@ -301,15 +301,14 @@ print_string_repr (PyObject *printer, const char *hint,
CORE_ADDR addr;
long length;
struct type *type;
char *encoding = NULL;
gdb::unique_xmalloc_ptr<char> encoding;
struct value_print_options local_opts = *options;
make_cleanup (free_current_contents, &encoding);
gdbpy_extract_lazy_string (py_str, &addr, &type,
&length, &encoding);
local_opts.addressprint = 0;
val_print_string (type, encoding, addr, (int) length,
val_print_string (type, encoding.get (), addr, (int) length,
stream, &local_opts);
}
else
@ -610,14 +609,13 @@ print_children (PyObject *printer, const char *hint,
CORE_ADDR addr;
struct type *type;
long length;
char *encoding = NULL;
gdb::unique_xmalloc_ptr<char> encoding;
struct value_print_options local_opts = *options;
make_cleanup (free_current_contents, &encoding);
gdbpy_extract_lazy_string (py_v, &addr, &type, &length, &encoding);
local_opts.addressprint = 0;
val_print_string (type, encoding, addr, (int) length, stream,
val_print_string (type, encoding.get (), addr, (int) length, stream,
&local_opts);
}
else if (gdbpy_is_string (py_v))