aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-value.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-value.c')
-rw-r--r--gdb/python/py-value.c19
1 files changed, 6 insertions, 13 deletions
diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c
index 926a09c..b959f2e 100644
--- a/gdb/python/py-value.c
+++ b/gdb/python/py-value.c
@@ -667,7 +667,7 @@ valpy_getitem (PyObject *self, PyObject *key)
{
struct gdb_exception except = exception_none;
value_object *self_value = (value_object *) self;
- char *field = NULL;
+ gdb::unique_xmalloc_ptr<char> field;
struct type *base_class_type = NULL, *field_type = NULL;
long bitpos = -1;
PyObject *result = NULL;
@@ -754,7 +754,7 @@ valpy_getitem (PyObject *self, PyObject *key)
struct value *res_val = NULL;
if (field)
- res_val = value_struct_elt (&tmp, NULL, field, NULL,
+ res_val = value_struct_elt (&tmp, NULL, field.get (), NULL,
"struct/class/union");
else if (bitpos >= 0)
res_val = value_struct_elt_bitpos (&tmp, bitpos, field_type,
@@ -804,7 +804,6 @@ valpy_getitem (PyObject *self, PyObject *key)
}
END_CATCH
- xfree (field);
GDB_PY_HANDLE_EXCEPTION (except);
return result;
@@ -1663,17 +1662,11 @@ convert_value_from_python (PyObject *obj)
}
else if (gdbpy_is_string (obj))
{
- char *s;
-
- s = python_string_to_target_string (obj);
+ gdb::unique_xmalloc_ptr<char> s
+ = python_string_to_target_string (obj);
if (s != NULL)
- {
- struct cleanup *old;
-
- old = make_cleanup (xfree, s);
- value = value_cstring (s, strlen (s), builtin_type_pychar);
- do_cleanups (old);
- }
+ value = value_cstring (s.get (), strlen (s.get ()),
+ builtin_type_pychar);
}
else if (PyObject_TypeCheck (obj, &value_object_type))
value = value_copy (((value_object *) obj)->value);