dovecot-2.2: lib-index: Added mail_index_ext_resize_hdr()

dovecot at dovecot.org dovecot at dovecot.org
Mon May 27 20:45:15 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/bd8ec99cf502
changeset: 16402:bd8ec99cf502
user:      Timo Sirainen <tss at iki.fi>
date:      Mon May 27 20:45:08 2013 +0300
description:
lib-index: Added mail_index_ext_resize_hdr()

diffstat:

 src/lib-index/mail-index-transaction-update.c |  24 ++++++++++++++++++++----
 src/lib-index/mail-index.h                    |   3 +++
 2 files changed, 23 insertions(+), 4 deletions(-)

diffs (76 lines):

diff -r ad78dcbe67be -r bd8ec99cf502 src/lib-index/mail-index-transaction-update.c
--- a/src/lib-index/mail-index-transaction-update.c	Mon May 27 20:44:56 2013 +0300
+++ b/src/lib-index/mail-index-transaction-update.c	Mon May 27 20:45:08 2013 +0300
@@ -717,7 +717,7 @@
 			   uint16_t record_align)
 {
 	struct mail_transaction_ext_intro intro;
-	uint32_t old_record_size, old_record_align;
+	uint32_t old_record_size, old_record_align, old_header_size;
 
 	memset(&intro, 0, sizeof(intro));
 
@@ -730,17 +730,20 @@
 		rext = array_idx(&t->view->index->extensions, ext_id);
 		old_record_size = rext->record_size;
 		old_record_align = rext->record_align;
+		old_header_size = rext->hdr_size;
 	} else {
 		const struct mail_index_ext *ext;
 
 		ext = array_idx(&t->view->map->extensions, intro.ext_id);
 		old_record_size = ext->record_size;
 		old_record_align = ext->record_align;
+		old_header_size = ext->hdr_size;
 	}
 
 	/* allow only header size changes if extension records have already
 	   been changed in transaction */
 	i_assert(!array_is_created(&t->ext_rec_updates) ||
+		 record_size == (uint16_t)-1 ||
 		 (old_record_size == record_size &&
 		  old_record_align == record_align));
 
@@ -749,13 +752,26 @@
 	if (!array_is_created(&t->ext_resizes))
 		i_array_init(&t->ext_resizes, ext_id + 2);
 
-	intro.hdr_size = hdr_size;
-	intro.record_size = record_size;
-	intro.record_align = record_align;
+	intro.hdr_size = hdr_size != (uint32_t)-1 ? hdr_size : old_header_size;
+	if (record_size != (uint16_t)-1) {
+		i_assert(record_align != (uint16_t)-1);
+		intro.record_size = record_size;
+		intro.record_align = record_align;
+	} else {
+		i_assert(record_align == (uint16_t)-1);
+		intro.record_size = old_record_size;
+		intro.record_align = old_record_align;
+	}
 	intro.name_size = 1;
 	array_idx_set(&t->ext_resizes, ext_id, &intro);
 }
 
+void mail_index_ext_resize_hdr(struct mail_index_transaction *t,
+			       uint32_t ext_id, uint32_t hdr_size)
+{
+	mail_index_ext_resize(t, ext_id, hdr_size, (uint16_t)-1, (uint16_t)-1);
+}
+
 void mail_index_ext_reset(struct mail_index_transaction *t, uint32_t ext_id,
 			  uint32_t reset_id, bool clear_data)
 {
diff -r ad78dcbe67be -r bd8ec99cf502 src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h	Mon May 27 20:44:56 2013 +0300
+++ b/src/lib-index/mail-index.h	Mon May 27 20:45:08 2013 +0300
@@ -555,6 +555,9 @@
 void mail_index_ext_resize(struct mail_index_transaction *t, uint32_t ext_id,
 			   uint32_t hdr_size, uint16_t record_size,
 			   uint16_t record_align);
+/* Resize header, keeping the old record size. */
+void mail_index_ext_resize_hdr(struct mail_index_transaction *t,
+			       uint32_t ext_id, uint32_t hdr_size);
 
 /* Reset extension. Any updates for this extension which were issued before the
    writer had seen this reset are discarded. reset_id is used to figure this


More information about the dovecot-cvs mailing list