diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-12-17 22:56:22 -0800 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2014-01-02 14:34:42 -0800 |
commit | e6249ad007adeec2010ef8a8f8f7907b4d60fdfd (patch) | |
tree | 6f264ad769aefcd8250bd64ca3582cdd2ba96496 /giscanner | |
parent | 4a64ab0b8e3e6cf0ebb4f34dd9276e964e1f303c (diff) | |
download | gobject-introspection-e6249ad007adeec2010ef8a8f8f7907b4d60fdfd.tar.gz |
scanner: Fix get_symbols/comments to maintain the scanner lists
Use g_slist_copy prior to returning the lists run through g_slist_reverse.
This preserves the source scanners internally held lists where previously
they would only point to a single element after a call, leaking memory and
breaking subsequent calls. Note the functions as (transfer container) and
use g_slist_free after calls in the Python bindings.
Add new unittest file: test_sourcescanner.py for isolated unittesting of the
SourceScanner.
https://bugzilla.gnome.org/show_bug.cgi?id=581525
Diffstat (limited to 'giscanner')
-rw-r--r-- | giscanner/giscannermodule.c | 2 | ||||
-rw-r--r-- | giscanner/sourcescanner.c | 18 |
2 files changed, 18 insertions, 2 deletions
diff --git a/giscanner/giscannermodule.c b/giscanner/giscannermodule.c index 925b3e0a..b9512275 100644 --- a/giscanner/giscannermodule.c +++ b/giscanner/giscannermodule.c @@ -575,6 +575,7 @@ pygi_source_scanner_get_symbols (PyGISourceScanner *self) PyList_SetItem (list, i++, item); } + g_slist_free (symbols); Py_INCREF (list); return list; } @@ -598,6 +599,7 @@ pygi_source_scanner_get_comments (PyGISourceScanner *self) PyList_SetItem (list, i++, item); } + g_slist_free (comments); Py_INCREF (list); return list; } diff --git a/giscanner/sourcescanner.c b/giscanner/sourcescanner.c index 070397b4..7de891f5 100644 --- a/giscanner/sourcescanner.c +++ b/giscanner/sourcescanner.c @@ -309,14 +309,28 @@ gi_source_scanner_take_comment (GISourceScanner *scanner, comment); } +/** + * gi_source_scanner_get_symbols: + * @scanner: scanner instance + * + * Returns: (transfer container): List of GISourceSymbol. + * Free resulting list with g_slist_free(). + */ GSList * gi_source_scanner_get_symbols (GISourceScanner *scanner) { - return g_slist_reverse (scanner->symbols); + return g_slist_reverse (g_slist_copy (scanner->symbols)); } +/** + * gi_source_scanner_get_comments: + * @scanner: scanner instance + * + * Returns: (transfer container): List of GISourceComment. + * Free resulting list with g_slist_free(). + */ GSList * gi_source_scanner_get_comments(GISourceScanner *scanner) { - return g_slist_reverse (scanner->comments); + return g_slist_reverse (g_slist_copy (scanner->comments)); } |