diff options
author | Jeremy Kerr <jk@ozlabs.org> | 2013-10-18 13:20:57 +0800 |
---|---|---|
committer | Jeremy Kerr <jk@ozlabs.org> | 2013-10-21 19:30:08 +0800 |
commit | 0ed4725477f7676d7b3d72d5e5a1008bdb045e2d (patch) | |
tree | 94b2f50ae33ee33f17267e7fae5981d8b51be9d2 /discover | |
parent | 658244e405261ce92239b4002efcd2cd56d91470 (diff) | |
download | petitboot-0ed4725477f7676d7b3d72d5e5a1008bdb045e2d.zip petitboot-0ed4725477f7676d7b3d72d5e5a1008bdb045e2d.tar.gz |
discover/parser: free parsers on exit
Allocate parsers against a context, and free that context on exit.
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Diffstat (limited to 'discover')
-rw-r--r-- | discover/parser.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/discover/parser.c b/discover/parser.c index b066880..e83b994 100644 --- a/discover/parser.c +++ b/discover/parser.c @@ -171,14 +171,25 @@ void iterate_parsers(struct discover_context *ctx, enum conf_method method) } } +static void *parsers_ctx; + void __register_parser(struct parser *parser) { - struct p_item* i = talloc(NULL, struct p_item); + struct p_item *i; + + if (!parsers_ctx) + parsers_ctx = talloc_new(NULL); + i = talloc(parsers_ctx, struct p_item); i->parser = parser; list_add(&parsers, &i->list); } +static __attribute__((destructor)) void cleanup_parsers(void) +{ + talloc_free(parsers_ctx); +} + void parser_init(void) { } |