From: Pietro Cerutti Date: Mon, 13 May 2019 12:25:00 +0000 (+0000) Subject: Use AddressList in mutt_addr_append X-Git-Tag: 2019-10-25~200^2~68 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=47820920c2100e63f253ae8085820875beff34de;p=neomutt Use AddressList in mutt_addr_append --- diff --git a/address/address.c b/address/address.c index 98c4cf247..3637a69d4 100644 --- a/address/address.c +++ b/address/address.c @@ -795,22 +795,33 @@ struct Address *mutt_addr_append(struct Address **a, struct Address *b, bool pru if (!a) return NULL; - struct Address *tmp = *a; - - while (tmp && tmp->next) - tmp = tmp->next; + struct AddressList *ala = mutt_addr_to_addresslist(*a); if (!b) - return tmp; - if (tmp) - tmp->next = mutt_addr_copy_list(b, prune); - else { - *a = mutt_addr_copy_list(b, prune); - tmp = *a; + if (TAILQ_EMPTY(ala)) + return NULL; + else + return TAILQ_LAST(ala, AddressList)->addr; + } + + struct AddressList *alb = mutt_addr_to_addresslist(b); + struct AddressList *alb_pruned = mutt_addresslist_copy(alb, prune); + struct AddressNode *an = NULL; + TAILQ_FOREACH(an, alb_pruned, entries) + { + mutt_addresslist_append(ala, an->addr); + } + FREE(&alb); + FREE(&alb_pruned); + + struct Address *last = NULL; + if (!TAILQ_EMPTY(ala)) + { + last = TAILQ_LAST(ala, AddressList)->addr; } - while (tmp && tmp->next) - tmp = tmp->next; - return tmp; + *a = mutt_addresslist_to_addr(ala); + + return last; } /**