From 40a71c0342dd48ca60100a7e04a5a917a32cc416 Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Mon, 13 May 2019 12:23:52 +0000 Subject: [PATCH] Implement mutt_addresslist_new --- address/address.c | 15 ++++++++++++--- address/address.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/address/address.c b/address/address.c index 736bddf8f..6b789e862 100644 --- a/address/address.c +++ b/address/address.c @@ -1408,6 +1408,17 @@ struct Address *mutt_addr_remove_xrefs(struct Address *a, struct Address *b) return top; } +/** + * mutt_addresslist_new - Create a new AddressList + * @return a newly allocated AddressList + */ +struct AddressList *mutt_addresslist_new(void) +{ + struct AddressList *al = mutt_mem_calloc(1, sizeof(struct AddressList)); + TAILQ_INIT(al); + return al; +} + /** * mutt_addresslist_append - Append an address to an AddressList * @param al AddressList @@ -1430,9 +1441,7 @@ void mutt_addresslist_append(struct AddressList *al, struct Address *a) */ struct AddressList *mutt_addr_to_addresslist(struct Address *a) { - struct AddressList *al = mutt_mem_calloc(1, sizeof(struct AddressList)); - TAILQ_INIT(al); - + struct AddressList *al = mutt_addresslist_new(); while (a) { struct Address *next = a->next; diff --git a/address/address.h b/address/address.h index 171c7519e..f036c1adc 100644 --- a/address/address.h +++ b/address/address.h @@ -95,6 +95,7 @@ int mutt_addrlist_to_intl(struct Address *a, char **err); int mutt_addrlist_to_local(struct Address *a); struct AddressList *mutt_addr_to_addresslist(struct Address *a); +struct AddressList *mutt_addresslist_new(void); struct Address *mutt_addresslist_to_addr(struct AddressList *alist); void mutt_addresslist_append(struct AddressList *al, struct Address *a); void mutt_addresslist_free(struct AddressList **alist); -- 2.40.0