{
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;
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,
}
END_CATCH
- xfree (field);
GDB_PY_HANDLE_EXCEPTION (except);
return result;
}
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);