diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-04-19 19:25:04 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-04-19 19:25:04 (GMT) |
commit | c177597d6da5dedb32aa176e8370db8ffb7f87aa (patch) | |
tree | 26f7eb2702ba4aa3dfd7267d74fe78ad79791a8c /plugins/pychrysa/analysis/db/items | |
parent | 35f37c72e9d81e478395914da6c10b3c546761a7 (diff) |
Handled static strings as well as dynamic strings in comments.
Diffstat (limited to 'plugins/pychrysa/analysis/db/items')
-rw-r--r-- | plugins/pychrysa/analysis/db/items/comment.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/plugins/pychrysa/analysis/db/items/comment.c b/plugins/pychrysa/analysis/db/items/comment.c index 4a90f09..1062cc9 100644 --- a/plugins/pychrysa/analysis/db/items/comment.c +++ b/plugins/pychrysa/analysis/db/items/comment.c @@ -25,6 +25,7 @@ #include "comment.h" +#include <malloc.h> #include <pygobject.h> @@ -108,13 +109,25 @@ static PyObject *py_db_comment_new(PyTypeObject *type, PyObject *args, PyObject static PyObject *py_db_comment_get_text(PyObject *self, void *closure) { + PyObject *result; /* Résultat à retourner */ GDbComment *comment; /* Commentaire à consulter */ - const char *content; /* Contenu textuel associé */ + char *text; /* Contenu textuel associé */ comment = G_DB_COMMENT(pygobject_get(self)); - content = g_db_comment_get_text(comment); + text = g_db_comment_get_text(comment); - return PyUnicode_FromString(content); + if (text == NULL) + { + result = Py_None; + Py_INCREF(result); + } + else + { + result = PyUnicode_FromString(text); + free(text); + } + + return result; } |