Use gdbpy_ref to simplify some logic
[deliverable/binutils-gdb.git] / gdb / python / py-type.c
index 857c4e201a2178fd5b87a64a7d86224bcf670c6d..9c20582abe5b50eb7fa82ea9299904fc835d3ee0 100644 (file)
@@ -130,18 +130,16 @@ field_dealloc (PyObject *obj)
 static PyObject *
 field_new (void)
 {
-  field_object *result = PyObject_New (field_object, &field_object_type);
+  gdbpy_ref<field_object> result (PyObject_New (field_object,
+                                               &field_object_type));
 
-  if (result)
+  if (result != NULL)
     {
       result->dict = PyDict_New ();
       if (!result->dict)
-       {
-         Py_DECREF (result);
-         result = NULL;
-       }
+       return NULL;
     }
-  return (PyObject *) result;
+  return (PyObject *) result.release ();
 }
 
 \f
This page took 0.027142 seconds and 4 git commands to generate.