summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/helpers.c')
-rw-r--r--plugins/pychrysa/helpers.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/plugins/pychrysa/helpers.c b/plugins/pychrysa/helpers.c
index bc420c0..d8f7b0b 100644
--- a/plugins/pychrysa/helpers.c
+++ b/plugins/pychrysa/helpers.c
@@ -2,7 +2,7 @@
/* OpenIDA - Outil d'analyse de fichiers binaires
* helpers.c - simplification des interactions de base avec Python
*
- * Copyright (C) 2012 Cyrille Bagard
+ * Copyright (C) 2012-2013 Cyrille Bagard
*
* This file is part of OpenIDA.
*
@@ -49,6 +49,35 @@ PyObject *run_python_method(PyObject *module, const char *method, PyObject *args
func = PyObject_GetAttrString(module, method);
if (func == NULL) return NULL;
+ result = _run_python_method(func, args);
+
+ Py_DECREF(func);
+
+ return result;
+
+}
+
+
+
+/******************************************************************************
+* *
+* Paramètres : func = fonction Python à appeler. *
+* args = arguments à associer à l'opération. *
+* *
+* Description : Appelle une routine Python. *
+* *
+* Retour : Retour obtenu ou NULL si erreur. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+PyObject *_run_python_method(PyObject *func, PyObject *args)
+{
+ PyObject *result; /* Bilan à retourner */
+
+ result = NULL;
+
if (PyCallable_Check(func))
{
result = PyObject_CallObject(func, args);
@@ -56,8 +85,6 @@ PyObject *run_python_method(PyObject *module, const char *method, PyObject *args
}
else if (PyErr_Occurred()) PyErr_Print();
- Py_DECREF(func);
-
return result;
}