[dovecot-cvs] dovecot/src/plugins/zlib zlib-plugin.c,1.7,1.8

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


Update of /var/lib/cvs/dovecot/src/plugins/zlib
In directory talvi:/tmp/cvs-serv16171/plugins/zlib

Modified Files:
	zlib-plugin.c 
Log Message:
Better type safety to module_contexts arrays. Already fixed some bugs.



Index: zlib-plugin.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/zlib/zlib-plugin.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- zlib-plugin.c	15 Mar 2007 17:05:45 -0000	1.7
+++ zlib-plugin.c	29 Mar 2007 11:51:20 -0000	1.8
@@ -10,27 +10,22 @@
 
 #include <fcntl.h>
 
-struct zlib_mail_storage {
-	struct mail_storage_vfuncs super;
-};
-
 #define ZLIB_CONTEXT(obj) \
-	*((void **)array_idx_modifiable(&(obj)->module_contexts, \
-					zlib_storage_module_id))
+	MODULE_CONTEXT(obj, zlib_storage_module)
 
 const char *zlib_plugin_version = PACKAGE_VERSION;
 
 static void (*zlib_next_hook_mail_storage_created)
 	(struct mail_storage *storage);
 
-static unsigned int zlib_storage_module_id = 0;
-static bool zlib_storage_module_id_set = FALSE;
+static MODULE_CONTEXT_DEFINE_INIT(zlib_storage_module,
+				  &mail_storage_module_register);
 
 static struct mailbox *
 zlib_mailbox_open(struct mail_storage *storage, const char *name,
 		  struct istream *input, enum mailbox_open_flags flags)
 {
-	struct zlib_mail_storage *qstorage = ZLIB_CONTEXT(storage);
+	union mail_storage_module_context *qstorage = ZLIB_CONTEXT(storage);
 	struct mailbox *box;
 	struct istream *zlib_input = NULL;
 	size_t len = strlen(name);
@@ -63,22 +58,16 @@
 
 static void zlib_mail_storage_created(struct mail_storage *storage)
 {
-	struct zlib_mail_storage *qstorage;
+	union mail_storage_module_context *qstorage;
 
 	if (zlib_next_hook_mail_storage_created != NULL)
 		zlib_next_hook_mail_storage_created(storage);
 
-	qstorage = p_new(storage->pool, struct zlib_mail_storage, 1);
+	qstorage = p_new(storage->pool, union mail_storage_module_context, 1);
 	qstorage->super = storage->v;
 	storage->v.mailbox_open = zlib_mailbox_open;
 
-	if (!zlib_storage_module_id_set) {
-		zlib_storage_module_id = mail_storage_module_id++;
-		zlib_storage_module_id_set = TRUE;
-	}
-
-	array_idx_set(&storage->module_contexts,
-		      zlib_storage_module_id, &qstorage);
+	MODULE_CONTEXT_SET_SELF(storage, zlib_storage_module, qstorage);
 }
 
 void zlib_plugin_init(void)



More information about the dovecot-cvs mailing list