]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
imap: Code cleanup: Changed buffer to an array.
authorTimo Sirainen <tss@iki.fi>
Wed, 11 Mar 2009 20:11:55 +0000 (16:11 -0400)
committerTimo Sirainen <tss@iki.fi>
Wed, 11 Mar 2009 20:11:55 +0000 (16:11 -0400)
--HG--
branch : HEAD

src/imap/imap-fetch-body.c
src/imap/imap-fetch.c
src/imap/imap-fetch.h

index 39a338cc4580193d5f8551235e24d08e95abd6f3..4f5c87f03cd09860a2944ba8ae337286c462fdca 100644 (file)
@@ -655,8 +655,8 @@ static bool fetch_body_header_fields_init(struct imap_fetch_context *ctx,
        }
 
        for (arr = body->fields; *arr != NULL; arr++) {
-               char *hdr = p_strdup(ctx->cmd->pool, *arr);
-               buffer_append(ctx->all_headers_buf, &hdr, sizeof(hdr));
+               const char *hdr = p_strdup(ctx->cmd->pool, *arr);
+               array_append(&ctx->all_headers, &hdr, 1);
        }
 
        body->header_ctx = mailbox_header_lookup_init(ctx->box, body->fields);
index 13be734a16d50dab07f2b8b5844a0c308ed1b2ec..29b6e34be846a4cc7a85fe785981ba56e7ba249c 100644 (file)
@@ -102,7 +102,7 @@ imap_fetch_init(struct client_command_context *cmd, struct mailbox *box)
        ctx->box = box;
 
        ctx->cur_str = str_new(default_pool, 8192);
-       ctx->all_headers_buf = buffer_create_dynamic(cmd->pool, 128);
+       p_array_init(&ctx->all_headers, cmd->pool, 64);
        p_array_init(&ctx->handlers, cmd->pool, 16);
        p_array_init(&ctx->tmp_keywords, cmd->pool,
                     client->keywords.announce_count + 8);
@@ -314,7 +314,6 @@ imap_fetch_send_vanished(struct imap_fetch_context *ctx)
 
 int imap_fetch_begin(struct imap_fetch_context *ctx)
 {
-       const void *null = NULL;
        const void *data;
 
        if (ctx->send_vanished) {
@@ -333,12 +332,12 @@ int imap_fetch_begin(struct imap_fetch_context *ctx)
                }
        }
 
-       if (buffer_get_used_size(ctx->all_headers_buf) != 0 &&
+       if (array_count(&ctx->all_headers) > 0 &&
            ((ctx->fetch_data & (MAIL_FETCH_STREAM_HEADER |
                                 MAIL_FETCH_STREAM_BODY)) == 0)) {
-               buffer_append(ctx->all_headers_buf, &null, sizeof(null));
+               (void)array_append_space(&ctx->all_headers);
 
-               data = buffer_get_data(ctx->all_headers_buf, NULL);
+               data = array_idx(&ctx->all_headers, 0);
                ctx->all_headers_ctx =
                        mailbox_header_lookup_init(ctx->box, data);
        }
index 0a069c0a7e415f3a5eb5681854ee140f5b2a0b01..b041dc6f435b3a73ef5418ac1c10f2c37f03a721 100644 (file)
@@ -38,7 +38,7 @@ struct imap_fetch_context {
        struct mail *mail;
 
        enum mail_fetch_field fetch_data;
-       buffer_t *all_headers_buf;
+       ARRAY_TYPE(const_string) all_headers;
         struct mailbox_header_lookup_ctx *all_headers_ctx;
 
        ARRAY_DEFINE(handlers, struct imap_fetch_context_handler);