changeset 5642:7274df228c04 HEAD

Added mail_index_transction_reset().
author Timo Sirainen <tss@iki.fi>
date Tue, 22 May 2007 18:31:35 +0300
parents 209a71c37012
children 453128e12b11
files src/lib-index/mail-index-transaction.c src/lib-index/mail-index.h
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-transaction.c	Tue May 22 15:43:51 2007 +0300
+++ b/src/lib-index/mail-index-transaction.c	Tue May 22 18:31:35 2007 +0300
@@ -18,7 +18,7 @@
 void (*hook_mail_index_transaction_created)
 		(struct mail_index_transaction *t) = NULL;
 
-static void mail_index_transaction_free(struct mail_index_transaction *t)
+void mail_index_transction_reset(struct mail_index_transaction *t)
 {
 	ARRAY_TYPE(seq_array) *recs;
 	unsigned i, count;
@@ -60,6 +60,28 @@
 	if (array_is_created(&t->ext_resets))
 		array_free(&t->ext_resets);
 
+	t->first_new_seq = mail_index_view_get_messages_count(t->view)+1;
+	t->last_new_seq = 0;
+	t->last_update_idx = 0;
+
+	memset(t->pre_hdr_mask, 0, sizeof(t->pre_hdr_mask));
+	memset(t->post_hdr_mask, 0, sizeof(t->post_hdr_mask));
+
+	if (t->cache_trans_ctx != NULL) {
+		mail_cache_transaction_rollback(t->cache_trans_ctx);
+                t->cache_trans_ctx = NULL;
+	}
+
+	t->appends_nonsorted = FALSE;
+	t->pre_hdr_changed = FALSE;
+	t->post_hdr_changed = FALSE;
+	t->log_updates = FALSE;
+}
+
+static void mail_index_transaction_free(struct mail_index_transaction *t)
+{
+	mail_index_transction_reset(t);
+
 	array_free(&t->module_contexts);
 	mail_index_view_transaction_unref(t->view);
 	mail_index_view_close(&t->view);
--- a/src/lib-index/mail-index.h	Tue May 22 15:43:51 2007 +0300
+++ b/src/lib-index/mail-index.h	Tue May 22 18:31:35 2007 +0300
@@ -187,6 +187,8 @@
 				  uint32_t *log_file_seq_r,
 				  uoff_t *log_file_offset_r);
 void mail_index_transaction_rollback(struct mail_index_transaction **t);
+/* Discard all changes in the transaction. */
+void mail_index_transction_reset(struct mail_index_transaction *t);
 
 /* Returns a view to transaction. Currently this differs from normal view only
    in that it contains newly appended messages in transaction. The view can