From: Timo Sirainen Date: Wed, 11 Mar 2009 20:11:55 +0000 (-0400) Subject: imap: Code cleanup: Changed buffer to an array. X-Git-Tag: 1.2.beta2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a342a31752dd71ac444259ca57ad33ea6b79a572;p=thirdparty%2Fdovecot%2Fcore.git imap: Code cleanup: Changed buffer to an array. --HG-- branch : HEAD --- diff --git a/src/imap/imap-fetch-body.c b/src/imap/imap-fetch-body.c index 39a338cc45..4f5c87f03c 100644 --- a/src/imap/imap-fetch-body.c +++ b/src/imap/imap-fetch-body.c @@ -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); diff --git a/src/imap/imap-fetch.c b/src/imap/imap-fetch.c index 13be734a16..29b6e34be8 100644 --- a/src/imap/imap-fetch.c +++ b/src/imap/imap-fetch.c @@ -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); } diff --git a/src/imap/imap-fetch.h b/src/imap/imap-fetch.h index 0a069c0a7e..b041dc6f43 100644 --- a/src/imap/imap-fetch.h +++ b/src/imap/imap-fetch.h @@ -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);