2 ===================================================================
3 RCS file: /home/roessler/cvs/mutt/thread.c,v
4 retrieving revision 2.15
5 diff -I! -ICVS -u -r2.15 thread.c
6 --- thread.c 2001/04/25 22:08:41 2.15
7 +++ thread.c 2001/07/26 02:18:11
10 HEADER *mutt_sort_subthreads (HEADER *hdr, sort_t *func)
14 + static HEADER **array = NULL;
15 + static unsigned array_size = 0, array_alloc = 0;
16 + unsigned array_alloc_base;
17 + unsigned items, item;
23 + array_alloc_base = array_alloc;
24 + for (item = array_alloc_base; hdr; hdr = hdr->next)
28 - insert_message (&top, t, func);
30 - t->child = mutt_sort_subthreads (t->child, func);
31 + if (item >= array_size)
33 + array_size = 2 * MAX(array_size, 0x100);
34 + safe_realloc ((void **) &array, array_size * sizeof (*array));
36 + array[item++] = hdr;
40 + hdr->child = mutt_sort_subthreads (hdr->child, func);
44 + array_alloc = array_alloc_base;
46 + items = item - array_alloc_base;
47 + qsort ((void *) (array + array_alloc_base), items, sizeof (*array), func);
49 + array[array_alloc_base ]->prev = NULL;
50 + array[array_alloc_base + items-1]->next = NULL;
52 + for (item = array_alloc_base; item < array_alloc_base + items-1; item++)
54 + array[item ]->next = array[item+1];
55 + array[item+1]->prev = array[item ];
58 + return array[array_alloc_base];
61 void mutt_sort_threads (CONTEXT *ctx, int init)
63 - sort_t *usefunc = NULL;
71 - /* if the SORT_LAST bit is set, we save sorting for later */
72 - if (!(Sort & SORT_LAST))
73 - usefunc = mutt_get_sort_func (Sort);
75 for (i = 0; i < ctx->msgcount; i++)
79 CUR->subject_changed = 1;
80 unlink_message (&CUR->parent->child, CUR);
82 - insert_message (&ctx->tree, CUR, usefunc);
83 + insert_message (&ctx->tree, CUR, NULL);
85 else if (!CUR->threaded)
88 * parent) during the initial threading.
90 if (CUR->env->message_id)
91 - move_descendants (tmp ? &tmp->child : &ctx->tree, CUR, usefunc);
92 + move_descendants (tmp ? &tmp->child : &ctx->tree, CUR, NULL);
94 - insert_message (tmp ? &tmp->child : &ctx->tree, CUR, usefunc);
95 + insert_message (tmp ? &tmp->child : &ctx->tree, CUR, NULL);
100 if (!option (OPTSTRICTTHREADS))
101 - pseudo_threads (ctx, usefunc);
102 + pseudo_threads (ctx, NULL);
104 + /* if the SORT_LAST bit is not set, sort the whole tree now */
105 + if (!(Sort & SORT_LAST))
106 + ctx->tree = mutt_sort_subthreads (ctx->tree, mutt_get_sort_func (Sort));
108 /* now that the whole tree is put together, we can sort by last-* */
109 if (Sort & SORT_LAST)