From: Timo Sirainen Date: Fri, 17 Apr 2026 13:46:10 +0000 (+0200) Subject: [PATCH 05/14] lib-mail: Add count field to struct message_address_list X-Git-Tag: archive/raspbian/1%2.4.1+dfsg1-6+rpi1+deb13u7^2~59 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a694a694600c622be7fa935228340843a776fac3;p=dovecot.git [PATCH 05/14] lib-mail: Add count field to struct message_address_list Add a count field and increment it in add_address() so callers can read the number of parsed addresses directly from the list struct without walking the linked list. Co-Authored-By: Claude Sonnet 4.6 Gbp-Pq: Name 0005-lib-mail-Add-count-field-to-struct-message_address_l.patch --- diff --git a/src/lib-mail/message-address.c b/src/lib-mail/message-address.c index 675e652..967cc51 100644 --- a/src/lib-mail/message-address.c +++ b/src/lib-mail/message-address.c @@ -30,6 +30,7 @@ static void add_address(struct message_address_parser_context *ctx) i_zero(&ctx->addr); DLLIST2_APPEND(&ctx->addr_list.head, &ctx->addr_list.tail, addr); + ctx->addr_list.count++; } /* quote with "" and escape all '\', '"' and "'" characters if need */ diff --git a/src/lib-mail/message-address.h b/src/lib-mail/message-address.h index 224f7a7..8b99ce1 100644 --- a/src/lib-mail/message-address.h +++ b/src/lib-mail/message-address.h @@ -33,6 +33,7 @@ struct message_address { struct message_address_list { struct message_address *head, *tail; + unsigned int count; }; /* Parse message addresses from given data. Note that giving an empty string diff --git a/src/lib-mail/message-part-data.c b/src/lib-mail/message-part-data.c index 895bf88..acd50e5 100644 --- a/src/lib-mail/message-part-data.c +++ b/src/lib-mail/message-part-data.c @@ -247,6 +247,7 @@ void message_part_envelope_parse_from_header(pool_t pool, validated while MUA only shows the second From header. */ DLLIST2_JOIN(&addr_p->head, &addr_p->tail, &new_addr.head, &new_addr.tail); + addr_p->count += new_addr.count; } else if (str_p != NULL) { *str_p = message_header_strdup(pool, hdr->full_value, hdr->full_value_len);