aboutsummaryrefslogtreecommitdiff
path: root/gdb/python/py-utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'gdb/python/py-utils.c')
-rw-r--r--gdb/python/py-utils.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gdb/python/py-utils.c b/gdb/python/py-utils.c
index eac161f..d87eb8c 100644
--- a/gdb/python/py-utils.c
+++ b/gdb/python/py-utils.c
@@ -431,3 +431,18 @@ gdb_py_generic_dict (PyObject *self, void *closure)
Py_INCREF (result);
return result;
}
+
+/* Like PyModule_AddObject, but does not steal a reference to
+ OBJECT. */
+
+int
+gdb_pymodule_addobject (PyObject *module, const char *name, PyObject *object)
+{
+ int result;
+
+ Py_INCREF (object);
+ result = PyModule_AddObject (module, name, object);
+ if (result < 0)
+ Py_DECREF (object);
+ return result;
+}