From 9d51bd9c70df1ea91a1051b1005e59fe220fd375 Mon Sep 17 00:00:00 2001 From: Jeremy Kerr Date: Mon, 19 Aug 2013 11:08:36 +0800 Subject: [PATCH 1/1] test/lib: Use talloc in list test .. so we can free at exit Signed-off-by: Jeremy Kerr --- test/lib/list-test.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; } -- 2.39.2