From 4f10cabb8b36df61425b873df2226896432ba581 Mon Sep 17 00:00:00 2001 From: Consolatis <35009135+Consolatis@users.noreply.github.com> Date: Sat, 16 Mar 2024 20:09:37 +0100 Subject: [PATCH] src/common/dir.c: reuse buf within the loop --- src/common/dir.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/common/dir.c b/src/common/dir.c index d474c313..5b1d14a5 100644 --- a/src/common/dir.c +++ b/src/common/dir.c @@ -87,10 +87,11 @@ find_dir(struct ctx *ctx) { char *debug = getenv("LABWC_DEBUG_DIR_CONFIG_AND_THEME"); + struct buf prefix; + buf_init(&prefix); for (int i = 0; ctx->dirs[i].path; i++) { struct dir d = ctx->dirs[i]; - struct buf prefix; - buf_init(&prefix); + buf_clear(&prefix); /* * Replace (rather than augment) $HOME/.config with @@ -100,7 +101,6 @@ find_dir(struct ctx *ctx) char *pfxenv = getenv(d.prefix); buf_add(&prefix, pfxenv ? pfxenv : d.default_prefix); if (!prefix.len) { - buf_finish(&prefix); continue; } @@ -130,8 +130,8 @@ find_dir(struct ctx *ctx) wl_list_append(ctx->list, &path->link); } g_strfreev(prefixes); - buf_finish(&prefix); } + buf_finish(&prefix); } void