mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
xmalloc: remove delim param from xstrjoin() and add separate xstrjoin3()
This avoids the need for an unused third argument for most xstrjoin() calls and replaces the cases where it's needed with a more flexible function. Code generation is the same in both cases, when there are 2 string params and a compile-time known delimiter. This commit also converts 4 uses of xasprintf() to use xstrjoin*(). See also: https://godbolt.org/z/xsjrhv9b6
This commit is contained in:
parent
62b0b65d47
commit
f87c9bb9f7
7 changed files with 44 additions and 31 deletions
4
slave.c
4
slave.c
|
|
@ -55,7 +55,7 @@ find_file_in_path(const char *file)
|
|||
path != NULL;
|
||||
path = strtok(NULL, ":"))
|
||||
{
|
||||
char *full = xasprintf("%s/%s", path, file);
|
||||
char *full = xstrjoin3(path, "/", file);
|
||||
if (access(full, F_OK) == 0) {
|
||||
free(path_list);
|
||||
return full;
|
||||
|
|
@ -329,7 +329,7 @@ add_to_env(struct environ *env, const char *name, const char *value)
|
|||
if (env->envp == NULL)
|
||||
setenv(name, value, 1);
|
||||
else {
|
||||
char *e = xasprintf("%s=%s", name, value);
|
||||
char *e = xstrjoin3(name, "=", value);
|
||||
|
||||
/* Search for existing variable. If found, replace it with the
|
||||
new value */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue