[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.c, 1.154, 1.155 maildir-storage.h, 1.65, 1.66 maildir-transaction.c, 1.15, 1.16

tss at dovecot.org tss at dovecot.org
Thu Mar 29 14:51:29 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv16171/lib-storage/index/maildir

Modified Files:
	maildir-storage.c maildir-storage.h maildir-transaction.c 
Log Message:
Better type safety to module_contexts arrays. Already fixed some bugs.



Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.154
retrieving revision 1.155
diff -u -d -r1.154 -r1.155
--- maildir-storage.c	29 Mar 2007 07:59:19 -0000	1.154
+++ maildir-storage.c	29 Mar 2007 11:51:27 -0000	1.155
@@ -26,8 +26,7 @@
 #define MAILDIR_SUBFOLDER_FILENAME "maildirfolder"
 
 #define MAILDIR_LIST_CONTEXT(obj) \
-	*((void **)array_idx_modifiable(&(obj)->module_contexts, \
-					maildir_mailbox_list_module_id))
+	MODULE_CONTEXT(obj, maildir_mailbox_list_module)
 
 struct rename_context {
 	bool found;
@@ -38,7 +37,8 @@
 extern struct mail_storage maildir_storage;
 extern struct mailbox maildir_mailbox;
 
-static unsigned int maildir_mailbox_list_module_id = 0;
+static MODULE_CONTEXT_DEFINE_INIT(maildir_mailbox_list_module,
+				  &mailbox_list_module_register);
 
 static int verify_inbox(struct mail_storage *storage,
 			enum mailbox_open_flags *flags);
@@ -178,7 +178,7 @@
 	struct maildir_storage *storage = MAILDIR_LIST_CONTEXT(list);
 	const char *p;
 
-	if (!storage->list_super.is_valid_existing_name(list, name))
+	if (!storage->list_module_ctx.super.is_valid_existing_name(list, name))
 		return FALSE;
 
 	/* Don't allow the mailbox name to end in cur/new/tmp */
@@ -195,7 +195,7 @@
 	const char *const *tmp;
 	bool ret = TRUE;
 
-	if (!storage->list_super.is_valid_create_name(list, name))
+	if (!storage->list_module_ctx.super.is_valid_create_name(list, name))
 		return FALSE;
 
 	/* Don't allow creating mailboxes under cur/new/tmp */
@@ -250,7 +250,7 @@
 		pool_unref(pool);
 		return NULL;
 	}
-	storage->list_super = list->v;
+	storage->list_module_ctx.super = list->v;
 	if (strcmp(layout, MAILDIR_PLUSPLUS_DRIVER_NAME) == 0) {
 		list->v.iter_is_mailbox = maildirplusplus_iter_is_mailbox;
 	} else {
@@ -263,8 +263,8 @@
 	list->v.delete_mailbox = maildir_list_delete_mailbox;
 	list->v.rename_mailbox = maildir_list_rename_mailbox;
 
-	array_idx_set(&list->module_contexts,
-		      maildir_mailbox_list_module_id, &storage);
+	MODULE_CONTEXT_SET_FULL(list, maildir_mailbox_list_module,
+				storage, &storage->list_module_ctx);
 
 	storage->copy_with_hardlinks =
 		getenv("MAILDIR_COPY_WITH_HARDLINKS") != NULL;
@@ -797,7 +797,7 @@
 	index_storage_destroy_unrefed();
 
 	/* delete the index and control directories */
-	if (storage->list_super.delete_mailbox(list, name) < 0)
+	if (storage->list_module_ctx.super.delete_mailbox(list, name) < 0)
 		return -1;
 
 	/* check if the mailbox actually exists */
@@ -873,7 +873,8 @@
 		}
 	}
 
-	return storage->list_super.rename_mailbox(list, oldname, newname);
+	return storage->list_module_ctx.super.
+		rename_mailbox(list, oldname, newname);
 }
 
 static int maildir_storage_close(struct mailbox *box)
@@ -1054,7 +1055,6 @@
 
 static void maildir_class_init(void)
 {
-	maildir_mailbox_list_module_id = mailbox_list_module_id++;
 	maildir_transaction_class_init();
 }
 

Index: maildir-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- maildir-storage.h	29 Mar 2007 07:59:19 -0000	1.65
+++ maildir-storage.h	29 Mar 2007 11:51:27 -0000	1.66
@@ -57,7 +57,7 @@
 struct maildir_storage {
 	struct index_storage storage;
 
-	struct mailbox_list_vfuncs list_super;
+	union mailbox_list_module_context list_module_ctx;
 	const char *temp_prefix;
 
 	unsigned int copy_with_hardlinks:1;
@@ -94,6 +94,8 @@
 
 struct maildir_transaction_context {
 	struct index_transaction_context ictx;
+	union mail_index_transaction_module_context module_ctx;
+
 	struct maildir_save_context *save_ctx;
 };
 

Index: maildir-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-transaction.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- maildir-transaction.c	25 Jan 2007 17:24:47 -0000	1.15
+++ maildir-transaction.c	29 Mar 2007 11:51:27 -0000	1.16
@@ -12,7 +12,7 @@
 				      uint32_t *log_file_seq_r,
 				      uoff_t *log_file_offset_r)
 {
-	struct maildir_transaction_context *mt = MAIL_STORAGE_TRANSACTION(t);
+	struct maildir_transaction_context *mt = MAIL_STORAGE_CONTEXT(t);
 	struct maildir_mailbox *mbox = (struct maildir_mailbox *)mt->ictx.ibox;
 	struct maildir_save_context *save_ctx;
 	bool syncing = t->sync_transaction;
@@ -48,7 +48,7 @@
 
 static void maildir_transaction_rollback(struct mail_index_transaction *t)
 {
-	struct maildir_transaction_context *mt = MAIL_STORAGE_TRANSACTION(t);
+	struct maildir_transaction_context *mt = MAIL_STORAGE_CONTEXT(t);
 
 	if (mt->save_ctx != NULL)
 		maildir_transaction_save_rollback(mt->save_ctx);
@@ -57,7 +57,7 @@
 
 void maildir_transaction_created(struct mail_index_transaction *t)
 {
-	struct mailbox *box = MAIL_STORAGE_INDEX(t->view->index);
+	struct mailbox *box = MAIL_STORAGE_CONTEXT(t->view->index);
 
 	/* index can be for mailbox list index, in which case box=NULL */
 	if (box != NULL &&
@@ -71,9 +71,7 @@
 
 		t->v.commit = maildir_transaction_commit;
 		t->v.rollback = maildir_transaction_rollback;
-
-		array_idx_set(&t->mail_index_transaction_module_contexts,
-			      mail_storage_mail_index_module_id, &mt);
+		MODULE_CONTEXT_SET(t, mail_storage_mail_index_module, mt);
 
 		index_transaction_init(&mt->ictx, &mbox->ibox);
 	}



More information about the dovecot-cvs mailing list