]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
SORT: Don't waste data stack memory when sorting many messages.
authorTimo Sirainen <tss@iki.fi>
Wed, 25 Feb 2009 19:26:25 +0000 (14:26 -0500)
committerTimo Sirainen <tss@iki.fi>
Wed, 25 Feb 2009 19:26:25 +0000 (14:26 -0500)
--HG--
branch : HEAD

src/lib-storage/index/index-sort-string.c

index 7f45986a95a5d1f456f81c6808bdc98780a89fda..b0e4a69f16efd99573611b203a49e9d9d1580e66 100644 (file)
@@ -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;