[dovecot-cvs] dovecot/src/lib-index mail-index-private.h, 1.82, 1.83 mail-index-transaction-private.h, 1.33, 1.34 mail-index-transaction.c, 1.88, 1.89 mail-index-view-private.h, 1.26, 1.27 mail-index.c, 1.271, 1.272 mail-index.h, 1.165, 1.166

tss at dovecot.org tss at dovecot.org
Thu Mar 29 17:19:49 EEST 2007


Update of /var/lib/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv19787

Modified Files:
	mail-index-private.h mail-index-transaction-private.h 
	mail-index-transaction.c mail-index-view-private.h 
	mail-index.c mail-index.h 
Log Message:
Better type safety to module_contexts arrays. Already fixed some bugs.



Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- mail-index-private.h	24 Mar 2007 21:20:06 -0000	1.82
+++ mail-index-private.h	29 Mar 2007 14:19:47 -0000	1.83
@@ -131,6 +131,14 @@
 	unsigned int write_atomic:1; /* copy to new file and rename() */
 };
 
+struct mail_index_module_register {
+	unsigned int id;
+};
+
+union mail_index_module_context {
+	struct mail_index_module_register *reg;
+};
+
 struct mail_index {
 	char *dir, *prefix;
 
@@ -172,8 +180,8 @@
 	uint32_t keywords_ext_id;
 	unsigned int last_grow_count;
 
-	/* Module-specific contexts. See mail_index_module_id. */
-	ARRAY_DEFINE(mail_index_module_contexts, void);
+	/* Module-specific contexts. */
+	ARRAY_DEFINE(module_contexts, union mail_index_module_context *);
 
 	char *error;
 	unsigned int nodiskspace:1;
@@ -191,6 +199,8 @@
 	unsigned int mapping:1;
 };
 
+extern struct mail_index_module_register mail_index_module_register;
+
 /* Add/replace sync handler for specified extra record. */
 void mail_index_register_expunge_handler(struct mail_index *index,
 					 uint32_t ext_id, bool call_always,

Index: mail-index-transaction-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction-private.h,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- mail-index-transaction-private.h	6 Mar 2007 20:19:08 -0000	1.33
+++ mail-index-transaction-private.h	29 Mar 2007 14:19:47 -0000	1.34
@@ -15,6 +15,10 @@
 	void (*rollback)(struct mail_index_transaction *t);
 };
 
+union mail_index_transaction_module_context {
+	struct mail_index_module_register *reg;
+};
+
 struct mail_index_transaction {
 	int refcount;
 
@@ -43,8 +47,9 @@
 
         struct mail_cache_transaction_ctx *cache_trans_ctx;
 
-	/* Module-specific contexts. See mail_index_module_id. */
-	ARRAY_DEFINE(mail_index_transaction_module_contexts, void);
+	/* Module-specific contexts. */
+	ARRAY_DEFINE(module_contexts,
+		     union mail_index_transaction_module_context *);
 
 	/* this transaction was created for index_sync_view view */
 	unsigned int sync_transaction:1;

Index: mail-index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.88
retrieving revision 1.89
diff -u -d -r1.88 -r1.89
--- mail-index-transaction.c	25 Mar 2007 18:25:50 -0000	1.88
+++ mail-index-transaction.c	29 Mar 2007 14:19:47 -0000	1.89
@@ -60,7 +60,7 @@
 	if (array_is_created(&t->ext_resets))
 		array_free(&t->ext_resets);
 
-	array_free(&t->mail_index_transaction_module_contexts);
+	array_free(&t->module_contexts);
 	mail_index_view_transaction_unref(t->view);
 	mail_index_view_close(&t->view);
 	i_free(t);
@@ -978,8 +978,8 @@
 		t->no_appends = TRUE;
 	}
 
-	array_create(&t->mail_index_transaction_module_contexts, default_pool,
-		     sizeof(void *), I_MIN(5, mail_index_module_id));
+	i_array_init(&t->module_contexts,
+		     I_MIN(5, mail_index_module_register.id));
 
 	if (hook_mail_index_transaction_created != NULL)
 		hook_mail_index_transaction_created(t);

Index: mail-index-view-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-private.h,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- mail-index-view-private.h	15 Oct 2006 12:59:43 -0000	1.26
+++ mail-index-view-private.h	29 Mar 2007 14:19:47 -0000	1.27
@@ -32,6 +32,10 @@
 			      const void **data_r, size_t *data_size_r);
 };
 
+union mail_index_view_module_context {
+	struct mail_index_module_register *reg;
+};
+
 struct mail_index_view {
 	int refcount;
 
@@ -56,8 +60,8 @@
 	/* Transaction log offsets which we don't want to return in view sync */
 	ARRAY_TYPE(view_log_sync_pos) syncs_hidden;
 
-	/* Module-specific contexts. See mail_index_module_id. */
-	ARRAY_DEFINE(mail_index_view_module_contexts, void);
+	/* Module-specific contexts. */
+	ARRAY_DEFINE(module_contexts, union mail_index_view_module_context *);
 
 	int transactions;
 	unsigned int lock_id;

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.271
retrieving revision 1.272
diff -u -d -r1.271 -r1.272
--- mail-index.c	26 Mar 2007 16:42:09 -0000	1.271
+++ mail-index.c	29 Mar 2007 14:19:47 -0000	1.272
@@ -19,7 +19,7 @@
 #include <time.h>
 #include <sys/stat.h>
 
-unsigned int mail_index_module_id = 0;
+struct mail_index_module_register mail_index_module_register = { 0 };
 
 static int mail_index_try_open_only(struct mail_index *index);
 static void mail_index_create_in_memory(struct mail_index *index,
@@ -38,8 +38,8 @@
 		pool_alloconly_create(MEMPOOL_GROWING"index extension", 1024);
 	p_array_init(&index->extensions, index->extension_pool, 5);
 	i_array_init(&index->sync_lost_handlers, 4);
-	array_create(&index->mail_index_module_contexts, default_pool,
-		     sizeof(void *), I_MIN(5, mail_index_module_id));
+	i_array_init(&index->module_contexts,
+		     I_MIN(5, mail_index_module_register.id));
 
 	index->mode = 0600;
 	index->gid = (gid_t)-1;
@@ -67,7 +67,7 @@
 
 	array_free(&index->sync_lost_handlers);
 	array_free(&index->keywords);
-	array_free(&index->mail_index_module_contexts);
+	array_free(&index->module_contexts);
 
 	i_free(index->error);
 	i_free(index->dir);

Index: mail-index.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.165
retrieving revision 1.166
diff -u -d -r1.165 -r1.166
--- mail-index.h	28 Dec 2006 16:28:29 -0000	1.165
+++ mail-index.h	29 Mar 2007 14:19:47 -0000	1.166
@@ -140,8 +140,6 @@
 	enum mail_index_sync_type type;
 };
 
-extern unsigned int mail_index_module_id;
-
 ARRAY_DEFINE_TYPE(keyword_indexes, unsigned int);
 
 struct mail_index;



More information about the dovecot-cvs mailing list