]> dgit.raspbian.org Git - dovecot.git/commitdiff
[PATCH 05/14] lib-mail: Add count field to struct message_address_list
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 17 Apr 2026 13:46:10 +0000 (15:46 +0200)
committerNoah Meyerhans <noahm@debian.org>
Wed, 16 Sep 2026 19:06:35 +0000 (15:06 -0400)
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 <noreply@anthropic.com>
Gbp-Pq: Name 0005-lib-mail-Add-count-field-to-struct-message_address_l.patch

src/lib-mail/message-address.c
src/lib-mail/message-address.h
src/lib-mail/message-part-data.c

index 675e652e04fbeeac838a8477df6b617248dfe41b..967cc518bfe912caafdddb6e20ff0675dda32117 100644 (file)
@@ -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 */
index 224f7a756050dd7c3792ca482aa093ff572250ab..8b99ce1401daa873fb03732f5555e6bdfe6f7536 100644 (file)
@@ -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
index 895bf88e852ebd8b369c0857af1723d0c5dbaf51..acd50e5210573394fa8f45ac5a7ca2ba9e29c124 100644 (file)
@@ -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);