src/common/dir.c: reuse buf within the loop

This commit is contained in:
Consolatis 2024-03-16 20:09:37 +01:00
parent a5a1757479
commit 4f10cabb8b

View file

@ -87,10 +87,11 @@ find_dir(struct ctx *ctx)
{ {
char *debug = getenv("LABWC_DEBUG_DIR_CONFIG_AND_THEME"); char *debug = getenv("LABWC_DEBUG_DIR_CONFIG_AND_THEME");
struct buf prefix;
buf_init(&prefix);
for (int i = 0; ctx->dirs[i].path; i++) { for (int i = 0; ctx->dirs[i].path; i++) {
struct dir d = ctx->dirs[i]; struct dir d = ctx->dirs[i];
struct buf prefix; buf_clear(&prefix);
buf_init(&prefix);
/* /*
* Replace (rather than augment) $HOME/.config with * Replace (rather than augment) $HOME/.config with
@ -100,7 +101,6 @@ find_dir(struct ctx *ctx)
char *pfxenv = getenv(d.prefix); char *pfxenv = getenv(d.prefix);
buf_add(&prefix, pfxenv ? pfxenv : d.default_prefix); buf_add(&prefix, pfxenv ? pfxenv : d.default_prefix);
if (!prefix.len) { if (!prefix.len) {
buf_finish(&prefix);
continue; continue;
} }
@ -130,8 +130,8 @@ find_dir(struct ctx *ctx)
wl_list_append(ctx->list, &path->link); wl_list_append(ctx->list, &path->link);
} }
g_strfreev(prefixes); g_strfreev(prefixes);
buf_finish(&prefix);
} }
buf_finish(&prefix);
} }
void void