squash
Signed-off-by: Allan McRae <allan@archlinux.org>
This commit is contained in:
parent
e58d799c47
commit
5473c9fd3f
1 changed files with 10 additions and 3 deletions
|
@ -410,7 +410,6 @@ typedef char *(*formatfn)(void*);
|
|||
static char *concat_list(alpm_list_t *lst, formatfn fn)
|
||||
{
|
||||
char *output = NULL, *tmp = NULL;
|
||||
asprintf(&output, "%s", "");
|
||||
|
||||
for(alpm_list_t *i = lst; i; i = alpm_list_next(i)) {
|
||||
char *str = fn ? fn(i->data) : i->data;
|
||||
|
@ -419,15 +418,23 @@ static char *concat_list(alpm_list_t *lst, formatfn fn)
|
|||
continue;
|
||||
}
|
||||
|
||||
tmp = output;
|
||||
if(tmp) {
|
||||
asprintf(&output, "%s %s", tmp, str);
|
||||
free(tmp);
|
||||
} else {
|
||||
asprintf(&output, "%s", str);
|
||||
}
|
||||
tmp = output;
|
||||
|
||||
if(fn) {
|
||||
free(str);
|
||||
}
|
||||
}
|
||||
|
||||
if(!output) {
|
||||
asprintf(&output, "%s", "");
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue