Mercurial > dovecot > original-hg > dovecot-1.2
changeset 9234:ae3e0ff64c94 HEAD
Transaction view: Fixed getting extension data from messages whose flags had changed.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 21 Jul 2009 15:01:05 -0400 |
parents | 518963e8a20d |
children | 8e66ca02b6f9 |
files | src/lib-index/mail-index-transaction-view.c |
diffstat | 1 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction-view.c Mon Jul 20 14:32:25 2009 -0400 +++ b/src/lib-index/mail-index-transaction-view.c Tue Jul 21 15:01:05 2009 -0400 @@ -19,8 +19,9 @@ buffer_t *lookup_return_data; uint32_t lookup_prev_seq; + unsigned int record_size; unsigned int recs_count; - struct mail_index_record *recs; + void *recs; }; static void tview_close(struct mail_index_view *view) @@ -71,10 +72,12 @@ static const struct mail_index_record * tview_apply_flag_updates(struct mail_index_view_transaction *tview, + struct mail_index_map *map, const struct mail_index_record *rec, uint32_t seq) { struct mail_index_transaction *t = tview->t; const struct mail_transaction_flag_update *updates; + struct mail_index_record *trec; unsigned int idx, count; /* see if there are any flag updates */ @@ -93,16 +96,20 @@ create a records array and return data from there */ if (tview->recs == NULL) { tview->recs_count = t->first_new_seq; - tview->recs = i_new(struct mail_index_record, - tview->recs_count); + tview->record_size = I_MAX(map->hdr.record_size, + tview->view.map->hdr.record_size); + tview->recs = i_malloc(tview->record_size * + tview->recs_count); } i_assert(tview->recs_count == t->first_new_seq); i_assert(seq > 0 && seq <= tview->recs_count); + i_assert(map->hdr.record_size <= tview->record_size); - tview->recs[seq-1] = *rec; - tview->recs[seq-1].flags |= updates[idx].add_flags; - tview->recs[seq-1].flags &= ~updates[idx].remove_flags; - return &tview->recs[seq-1]; + trec = PTR_OFFSET(tview->recs, (seq-1) * tview->record_size); + memcpy(trec, rec, map->hdr.record_size); + trec->flags |= updates[idx].add_flags; + trec->flags &= ~updates[idx].remove_flags; + return trec; } static const struct mail_index_record * @@ -122,7 +129,7 @@ } rec = tview->super->lookup_full(view, seq, map_r, expunged_r); - rec = tview_apply_flag_updates(tview, rec, seq); + rec = tview_apply_flag_updates(tview, *map_r, rec, seq); if (array_is_created(&tview->t->expunges) && seq_range_exists(&tview->t->expunges, seq))