Skip to content

Commit

Permalink
XDECREFs all in one place instead of complex deref logic
Browse files Browse the repository at this point in the history
Signed-off-by: Emerson Knapp <[email protected]>
  • Loading branch information
Emerson Knapp committed Apr 18, 2019
1 parent 17d1161 commit 8f1b6aa
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions rclpy/src/rclpy/_rclpy_qos_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,21 @@ PyObject * _create_py_qos_event(const char * class_name, PyObject * args)

pyqos_event_module = PyImport_ImportModule("rclpy.qos_event");
if (!pyqos_event_module) {
Py_DECREF(args);
return NULL;
goto cleanup;
}

pyqos_event_class = PyObject_GetAttrString(pyqos_event_module, class_name);
Py_DECREF(pyqos_event_module);
if (!pyqos_event_class) {
Py_DECREF(args);
return NULL;
goto cleanup;
}

pyqos_event = PyObject_CallObject(pyqos_event_class, args);
Py_DECREF(pyqos_event_class);
Py_DECREF(args);

cleanup:
Py_XDECREF(pyqos_event_module);
Py_XDECREF(pyqos_event_class);
Py_XDECREF(args);

return pyqos_event;
}

Expand Down

0 comments on commit 8f1b6aa

Please sign in to comment.