[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-storage.c, 1.39, 1.40 dbox-storage.h, 1.18, 1.19 dbox-transaction.c, 1.5, 1.6

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/dbox
In directory talvi:/tmp/cvs-serv16171/lib-storage/index/dbox

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



Index: dbox-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- dbox-storage.c	29 Mar 2007 07:59:18 -0000	1.39
+++ dbox-storage.c	29 Mar 2007 11:51:26 -0000	1.40
@@ -23,8 +23,7 @@
 #define DBOX_LOCK_TOUCH_MSECS (10*1000)
 
 #define DBOX_LIST_CONTEXT(obj) \
-	*((void **)array_idx_modifiable(&(obj)->module_contexts, \
-					dbox_mailbox_list_module_id))
+	MODULE_CONTEXT(obj, dbox_mailbox_list_module)
 
 const struct dotlock_settings default_uidlist_dotlock_set = {
 	MEMBER(temp_prefix) NULL,
@@ -68,7 +67,8 @@
 extern struct mail_storage dbox_storage;
 extern struct mailbox dbox_mailbox;
 
-static unsigned int dbox_mailbox_list_module_id = 0;
+static MODULE_CONTEXT_DEFINE_INIT(dbox_mailbox_list_module,
+				  &mailbox_list_module_register);
 
 static int
 dbox_list_delete_mailbox(struct mailbox_list *list, const char *name);
@@ -83,7 +83,7 @@
 	struct dbox_storage *storage = DBOX_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 dbox-Mails */
@@ -100,7 +100,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 dbox-Mails */
@@ -206,14 +206,14 @@
 		pool_unref(pool);
 		return NULL;
 	}
-	storage->list_super = list->v;
+	storage->list_module_ctx.super = list->v;
 	list->v.is_valid_existing_name = dbox_storage_is_valid_existing_name;
 	list->v.is_valid_create_name = dbox_storage_is_valid_create_name;
 	list->v.iter_is_mailbox = dbox_list_iter_is_mailbox;
 	list->v.delete_mailbox = dbox_list_delete_mailbox;
 
-	array_idx_set(&list->module_contexts,
-		      dbox_mailbox_list_module_id, &storage);
+	MODULE_CONTEXT_SET_FULL(list, dbox_mailbox_list_module,
+				storage, &storage->list_module_ctx);
 
 	storage->uidlist_dotlock_set = default_uidlist_dotlock_set;
 	storage->file_dotlock_set = default_file_dotlock_set;
@@ -462,7 +462,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;
 
 	path = mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_DIR);
@@ -600,7 +600,6 @@
 
 static void dbox_class_init(void)
 {
-	dbox_mailbox_list_module_id = mailbox_list_module_id++;
 	dbox_transaction_class_init();
 }
 

Index: dbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dbox-storage.h	29 Mar 2007 07:59:18 -0000	1.18
+++ dbox-storage.h	29 Mar 2007 11:51:26 -0000	1.19
@@ -15,7 +15,7 @@
 
 struct dbox_storage {
 	struct index_storage storage;
-	struct mailbox_list_vfuncs list_super;
+	union mailbox_list_module_context list_module_ctx;
 
 	struct dotlock_settings uidlist_dotlock_set;
 	struct dotlock_settings file_dotlock_set;
@@ -77,6 +77,7 @@
 
 struct dbox_transaction_context {
 	struct index_transaction_context ictx;
+	union mail_index_transaction_module_context module_ctx;
 
 	uint32_t first_saved_mail_seq;
 	struct dbox_save_context *save_ctx;

Index: dbox-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-transaction.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- dbox-transaction.c	25 Nov 2006 22:17:42 -0000	1.5
+++ dbox-transaction.c	29 Mar 2007 11:51:26 -0000	1.6
@@ -12,7 +12,7 @@
 				   uint32_t *log_file_seq_r,
 				   uoff_t *log_file_offset_r)
 {
-	struct dbox_transaction_context *dt = MAIL_STORAGE_TRANSACTION(t);
+	struct dbox_transaction_context *dt = MAIL_STORAGE_CONTEXT(t);
 	struct dbox_mailbox *dbox = (struct dbox_mailbox *)dt->ictx.ibox;
 	struct dbox_save_context *save_ctx;
 	bool syncing = t->sync_transaction;
@@ -54,7 +54,7 @@
 
 static void dbox_transaction_rollback(struct mail_index_transaction *t)
 {
-	struct dbox_transaction_context *dt = MAIL_STORAGE_TRANSACTION(t);
+	struct dbox_transaction_context *dt = MAIL_STORAGE_CONTEXT(t);
 
 	if (dt->save_ctx != NULL)
 		dbox_transaction_save_rollback(dt->save_ctx);
@@ -64,7 +64,7 @@
 
 void dbox_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, DBOX_STORAGE_NAME) == 0) {
@@ -77,9 +77,7 @@
 
 		t->v.commit = dbox_transaction_commit;
 		t->v.rollback = dbox_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, &dbox->ibox);
 	}



More information about the dovecot-cvs mailing list