[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-storage.c, 1.171, 1.172 mbox-storage.h, 1.49, 1.50 mbox-transaction.c, 1.17, 1.18

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


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

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



Index: mbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.c,v
retrieving revision 1.171
retrieving revision 1.172
diff -u -d -r1.171 -r1.172
--- mbox-storage.c	29 Mar 2007 07:59:20 -0000	1.171
+++ mbox-storage.c	29 Mar 2007 11:51:28 -0000	1.172
@@ -32,8 +32,7 @@
 	 (st).st_atime < (st).st_mtime ? MAILBOX_MARKED : MAILBOX_UNMARKED)
 
 #define MBOX_LIST_CONTEXT(obj) \
-	*((void **)array_idx_modifiable(&(obj)->module_contexts, \
-					mbox_mailbox_list_module_id))
+	MODULE_CONTEXT(obj, mbox_mailbox_list_module)
 
 /* NOTE: must be sorted for istream-header-filter. Note that it's not such
    a good idea to change this list, as the messages will then change from
@@ -69,7 +68,8 @@
 extern struct mail_storage mbox_storage;
 extern struct mailbox mbox_mailbox;
 
-static unsigned int mbox_mailbox_list_module_id = 0;
+static MODULE_CONTEXT_DEFINE_INIT(mbox_mailbox_list_module,
+				  &mailbox_list_module_register);
 
 static int mbox_list_iter_is_mailbox(struct mailbox_list_iterate_context *ctx,
 				     const char *dir, const char *fname,
@@ -387,7 +387,7 @@
 	struct mbox_storage *storage = MBOX_LIST_CONTEXT(list);
 	const char *path, *p;
 
-	path = storage->list_super.get_path(list, name, type);
+	path = storage->list_module_ctx.super.get_path(list, name, type);
 	if (type == MAILBOX_LIST_PATH_TYPE_CONTROL ||
 	    type == MAILBOX_LIST_PATH_TYPE_INDEX) {
 		p = strrchr(path, '/');
@@ -426,7 +426,7 @@
 		pool_unref(pool);
 		return NULL;
 	}
-	storage->list_super = list->v;
+	storage->list_module_ctx.super = list->v;
 	if (strcmp(layout, "fs") == 0 && *list_set.maildir_name == '\0') {
 		/* have to use .imap/ directories */
 		list->v.get_path = mbox_list_get_path;
@@ -434,8 +434,8 @@
 	list->v.iter_is_mailbox = mbox_list_iter_is_mailbox;
 	list->v.delete_mailbox = mbox_list_delete_mailbox;
 
-	array_idx_set(&list->module_contexts,
-		      mbox_mailbox_list_module_id, &storage);
+	MODULE_CONTEXT_SET_FULL(list, mbox_mailbox_list_module,
+				storage, &storage->list_module_ctx);
 
 	istorage = INDEX_STORAGE(storage);
 	istorage->storage = mbox_storage;
@@ -977,7 +977,7 @@
 
 	/* delete index / control files first */
 	index_storage_destroy_unrefed();
-	if (storage->list_super.delete_mailbox(list, name) < 0)
+	if (storage->list_module_ctx.super.delete_mailbox(list, name) < 0)
 		return -1;
 
 	if (unlink(path) < 0) {
@@ -998,7 +998,6 @@
 
 static void mbox_class_init(void)
 {
-	mbox_mailbox_list_module_id = mailbox_list_module_id++;
 	mbox_transaction_class_init();
 }
 

Index: mbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-storage.h,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- mbox-storage.h	22 Feb 2007 17:29:46 -0000	1.49
+++ mbox-storage.h	29 Mar 2007 11:51:28 -0000	1.50
@@ -22,7 +22,7 @@
 struct mbox_storage {
 	struct index_storage storage;
 
-	struct mailbox_list_vfuncs list_super;
+	union mailbox_list_module_context list_module_ctx;
 };
 
 struct mbox_mailbox {
@@ -56,6 +56,7 @@
 
 struct mbox_transaction_context {
 	struct index_transaction_context ictx;
+	union mail_index_transaction_module_context module_ctx;
 
 	struct mbox_save_context *save_ctx;
 	unsigned int mbox_lock_id;

Index: mbox-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-transaction.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mbox-transaction.c	10 Mar 2007 15:47:32 -0000	1.17
+++ mbox-transaction.c	29 Mar 2007 11:51:28 -0000	1.18
@@ -13,7 +13,7 @@
 				   uint32_t *log_file_seq_r,
 				   uoff_t *log_file_offset_r)
 {
-	struct mbox_transaction_context *mt = MAIL_STORAGE_TRANSACTION(t);
+	struct mbox_transaction_context *mt = MAIL_STORAGE_CONTEXT(t);
 	struct mbox_mailbox *mbox = (struct mbox_mailbox *)mt->ictx.ibox;
 	unsigned int lock_id = mt->mbox_lock_id;
 	enum mailbox_sync_flags flags = mt->ictx.commit_flags;
@@ -66,7 +66,7 @@
 
 static void mbox_transaction_rollback(struct mail_index_transaction *t)
 {
-	struct mbox_transaction_context *mt = MAIL_STORAGE_TRANSACTION(t);
+	struct mbox_transaction_context *mt = MAIL_STORAGE_CONTEXT(t);
 	struct mbox_mailbox *mbox = (struct mbox_mailbox *)mt->ictx.ibox;
 
 	if (mt->save_ctx != NULL)
@@ -79,7 +79,7 @@
 
 void mbox_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 && strcmp(box->storage->name, MBOX_STORAGE_NAME) == 0) {
@@ -92,9 +92,7 @@
 
 		t->v.commit = mbox_transaction_commit;
 		t->v.rollback = mbox_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