diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-05-20 10:28:23 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-05-20 10:28:23 +0800 |
commit | 7048bb4f8667dc0ce7cf46e96a8db07622d9a39f (patch) | |
tree | 35c5db367aa4c1b9a0e12c413964e730a69eee65 /test/parser | |
parent | e39b409ec6863ade2e070f7ed2236cee0ca46180 (diff) | |
download | talos-petitboot-7048bb4f8667dc0ce7cf46e96a8db07622d9a39f.tar.gz talos-petitboot-7048bb4f8667dc0ce7cf46e96a8db07622d9a39f.zip |
test/parser: cleanup parser allocations on exit
We should talloc_free the parser list once we're done, enabling
valgrind's leak check. Before:
[jk@pablo parser]$ valgrind ./test-null
...
==9330== HEAP SUMMARY:
==9330== in use at exit: 288 bytes in 3 blocks
==9330== total heap usage: 11 allocs, 8 frees, 1,177 bytes allocated
After:
[jk@pablo parser]$ valgrind ./test-null
...
==9940== HEAP SUMMARY:
==9940== in use at exit: 0 bytes in 0 blocks
==9940== total heap usage: 11 allocs, 11 frees, 1,177 bytes allocated
==9940==
==9940== All heap blocks were freed -- no leaks are possible
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'test/parser')
-rw-r--r-- | test/parser/utils.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/test/parser/utils.c b/test/parser/utils.c index 9a6b2e1..6f78c2f 100644 --- a/test/parser/utils.c +++ b/test/parser/utils.c @@ -32,6 +32,14 @@ void __register_parser(struct parser *parser) list_add(&parsers, &i->list); } +static void __attribute__((destructor)) __cleanup_parsers(void) +{ + struct p_item *item, *tmp; + + list_for_each_entry_safe(&parsers, item, tmp, list) + talloc_free(item); +} + static struct discover_device *test_create_device_simple( struct discover_context *ctx) { |