From: Jeremy Kerr Date: Mon, 19 Aug 2013 03:08:36 +0000 (+0800) Subject: test/lib: Use talloc in list test X-Git-Tag: v1.0.0~515 X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=commitdiff_plain;h=9d51bd9c70df1ea91a1051b1005e59fe220fd375 test/lib: Use talloc in list test .. so we can free at exit Signed-off-by: Jeremy Kerr --- diff --git a/test/lib/list-test.c b/test/lib/list-test.c index c532282..3f7952a 100644 --- a/test/lib/list-test.c +++ b/test/lib/list-test.c @@ -25,6 +25,7 @@ #include #include +#include int main(void) @@ -36,10 +37,13 @@ int main(void) STATIC_LIST(tester); struct item *item; struct item *tmp; + void *ctx; int i; + ctx = talloc_new(NULL); + for (i = 0; i < 5; i++) { - struct item *item = malloc(sizeof(struct item)); + struct item *item = talloc(ctx, struct item); item->value = i; @@ -83,5 +87,8 @@ int main(void) return EXIT_FAILURE; } fprintf(stderr, "-- done --\n"); + + talloc_free(ctx); + return EXIT_SUCCESS; }