From: Timo Sirainen Date: Wed, 25 Feb 2009 19:26:25 +0000 (-0500) Subject: SORT: Don't waste data stack memory when sorting many messages. X-Git-Tag: 1.2.beta2~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a203000ed248009c1808cf8b45f84b2c3d5b89e9;p=thirdparty%2Fdovecot%2Fcore.git SORT: Don't waste data stack memory when sorting many messages. --HG-- branch : HEAD --- diff --git a/src/lib-storage/index/index-sort-string.c b/src/lib-storage/index/index-sort-string.c index 7f45986a95..b0e4a69f16 100644 --- a/src/lib-storage/index/index-sort-string.c +++ b/src/lib-storage/index/index-sort-string.c @@ -271,15 +271,20 @@ static void index_sort_zeroes(struct sort_string_context *ctx) ctx->sort_strings = i_new(const char *, ctx->last_seq + 1); ctx->sort_string_pool = pool = pool_alloconly_create("sort strings", 1024*64); - str = t_str_new(512); + str = str_new(default_pool, 512); nodes = array_get_modifiable(&ctx->zero_nodes, &count); for (i = 0; i < count; i++) { i_assert(nodes[i].seq <= ctx->last_seq); - index_sort_header_get(mail, nodes[i].seq, sort_type, str); - ctx->sort_strings[nodes[i].seq] = str_len(str) == 0 ? "" : - p_strdup(pool, str_c(str)); + T_BEGIN { + index_sort_header_get(mail, nodes[i].seq, + sort_type, str); + ctx->sort_strings[nodes[i].seq] = + str_len(str) == 0 ? "" : + p_strdup(pool, str_c(str)); + } T_END; } + str_free(&str); /* we have all strings, sort nodes based on them */ static_zero_cmp_context = ctx;