j5

aditionnal tools for the s6 service manager
Log | Files | Refs | README

commit 8b4179256865659254b7b552a92ed51c2db0669d
parent ea833da3e10638d0782863435a56bad787aa1964
Author: Josuah Demangeon <mail@josuah.net>
Date:   Sun, 27 Jan 2019 17:19:33 +0100

do not forget to free!

Diffstat:
Mj5-envdir.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/j5-envdir.c b/j5-envdir.c @@ -90,7 +90,8 @@ main(int argc, char **argv) int flag_e = 0; char *flag_f = NULL; char *flag_n = " \t\n"; - genalloc ga; + genalloc ga = GENALLOC_ZERO; + stralloc sa = STRALLOC_ZERO; ARG_BEGIN { case 'a': flag_a = 1; break; @@ -104,10 +105,11 @@ main(int argc, char **argv) if (!*argv) usage(arg_0); if (!(dp = opendir(*argv))) log_fatal_sys_2(101, "opendir ", *argv); + while ((de = readdir(dp))) { keyval a; - stralloc sa = STRALLOC_ZERO; + stralloc_zero(&sa); stralloc_init(&a.val); stralloc_cats(&sa, *argv); stralloc_cats(&sa, "/"); @@ -121,6 +123,7 @@ main(int argc, char **argv) if (!genalloc_append(&ga, a)) die_nomem(); } ++argv; + stralloc_free(&sa); if (flag_a) { for (char **av = argv; *av; ++av) {