Use unique_xmalloc_ptr in Python code
[deliverable/binutils-gdb.git] / gdb / python / py-varobj.c
index 7e74454986cb993421fb047d45388157eb922593..72c876ce82a0415a62f19cdd4f93e7755a95e670 100644 (file)
@@ -75,10 +75,11 @@ py_varobj_iter_next (struct varobj_iter *self)
       if (PyErr_ExceptionMatches (gdbpy_gdb_memory_error))
        {
          PyObject *type, *value, *trace;
-         char *name_str, *value_str;
+         char *name_str;
 
          PyErr_Fetch (&type, &value, &trace);
-         value_str = gdbpy_exception_to_string (type, value);
+         gdb::unique_xmalloc_ptr<char>
+           value_str (gdbpy_exception_to_string (type, value));
          Py_XDECREF (type);
          Py_XDECREF (value);
          Py_XDECREF (trace);
@@ -90,9 +91,8 @@ py_varobj_iter_next (struct varobj_iter *self)
 
          name_str = xstrprintf ("<error at %d>",
                                 self->next_raw_index++);
-         item = Py_BuildValue ("(ss)", name_str, value_str);
+         item = Py_BuildValue ("(ss)", name_str, value_str.get ());
          xfree (name_str);
-         xfree (value_str);
          if (item == NULL)
            {
              gdbpy_print_stack ();
@@ -113,11 +113,11 @@ py_varobj_iter_next (struct varobj_iter *self)
       error (_("Invalid item from the child list"));
     }
 
-  vitem = XNEW (struct varobj_item);
+  vitem = new varobj_item ();
   vitem->value = convert_value_from_python (py_v);
   if (vitem->value == NULL)
     gdbpy_print_stack ();
-  vitem->name = xstrdup (name);
+  vitem->name = name;
 
   self->next_raw_index++;
   do_cleanups (back_to);
This page took 0.026924 seconds and 4 git commands to generate.