dovecot-2.2: lib-storage: Use const pointers for mail_namespace....

dovecot at dovecot.org dovecot at dovecot.org
Mon Oct 29 21:58:29 EET 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/62519d9334a5
changeset: 15354:62519d9334a5
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Oct 29 21:54:51 2012 +0200
description:
lib-storage: Use const pointers for mail_namespace.(set|unexpanded_set)

diffstat:

 src/lib-storage/mail-namespace.h           |   2 +-
 src/plugins/autocreate/autocreate-plugin.c |  14 +++++++++++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diffs (50 lines):

diff -r 275ca1a03cdd -r 62519d9334a5 src/lib-storage/mail-namespace.h
--- a/src/lib-storage/mail-namespace.h	Mon Oct 29 21:42:32 2012 +0200
+++ b/src/lib-storage/mail-namespace.h	Mon Oct 29 21:54:51 2012 +0200
@@ -70,7 +70,7 @@
 	/* FIXME: we should support multiple storages in one namespace */
 	struct mail_storage *storage;
 
-	struct mail_namespace_settings *set, *unexpanded_set;
+	const struct mail_namespace_settings *set, *unexpanded_set;
 	const struct mail_storage_settings *mail_set;
 
 	unsigned int special_use_mailboxes:1;
diff -r 275ca1a03cdd -r 62519d9334a5 src/plugins/autocreate/autocreate-plugin.c
--- a/src/plugins/autocreate/autocreate-plugin.c	Mon Oct 29 21:42:32 2012 +0200
+++ b/src/plugins/autocreate/autocreate-plugin.c	Mon Oct 29 21:54:51 2012 +0200
@@ -28,6 +28,7 @@
 {
 	struct mail_namespace *ns;
 	struct mailbox_settings *set;
+	struct mail_namespace_settings tmp_ns_set;
 
 	if (!uni_utf8_str_is_valid(vname)) {
 		i_error("autocreate: Mailbox name isn't valid UTF-8: %s",
@@ -42,8 +43,15 @@
 		return;
 	}
 
-	if (!array_is_created(&ns->set->mailboxes))
-		p_array_init(&ns->set->mailboxes, user->pool, 16);
+	if (array_is_created(&ns->set->mailboxes))
+		tmp_ns_set.mailboxes = ns->set->mailboxes;
+	else {
+		p_array_init(&tmp_ns_set.mailboxes, user->pool, 16);
+		/* work around ns->set being a const pointer. pretty ugly, but
+		   this plugin is deprecated anyway. */
+		memcpy((void *)&ns->set->mailboxes.arr, &tmp_ns_set.mailboxes.arr,
+		       sizeof(ns->set->mailboxes.arr));
+	}
 
 	if (strncmp(vname, ns->prefix, ns->prefix_len) == 0)
 		vname += ns->prefix_len;
@@ -53,7 +61,7 @@
 		set->name = p_strdup(user->pool, vname);
 		set->autocreate = MAILBOX_SET_AUTO_NO;
 		set->special_use = "";
-		array_append(&ns->set->mailboxes, &set, 1);
+		array_append(&tmp_ns_set.mailboxes, &set, 1);
 	}
 	if (subscriptions)
 		set->autocreate = MAILBOX_SET_AUTO_SUBSCRIBE;


More information about the dovecot-cvs mailing list