changeset 13218:bd0e7cdbb6b2

lib-storage: Added struct mailbox.generation_sequence. This can be used for caching struct mailbox pointers and checking later if two struct mailboxes + their generation sequences match. If they do, it's the same struct mailbox.
author Timo Sirainen <tss@iki.fi>
date Thu, 11 Aug 2011 18:02:25 +0300
parents a29438231cd2
children 7098642a0374
files src/lib-storage/index/index-storage.c src/lib-storage/mail-storage-private.h
diffstat 2 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-storage/index/index-storage.c	Thu Aug 11 17:35:45 2011 +0300
+++ b/src/lib-storage/index/index-storage.c	Thu Aug 11 18:02:25 2011 +0300
@@ -290,10 +290,12 @@
 				 enum mailbox_flags flags,
 				 const char *index_prefix)
 {
+	static unsigned int mailbox_generation_sequence = 0;
 	struct index_mailbox_context *ibox;
 
 	i_assert(vname != NULL);
 
+	box->generation_sequence = ++mailbox_generation_sequence;
 	box->vname = p_strdup(box->pool, vname);
 	box->name = p_strdup(box->pool,
 			     mailbox_list_get_storage_name(box->list, vname));
--- a/src/lib-storage/mail-storage-private.h	Thu Aug 11 17:35:45 2011 +0300
+++ b/src/lib-storage/mail-storage-private.h	Thu Aug 11 18:02:25 2011 +0300
@@ -245,6 +245,9 @@
 	mailbox_notify_callback_t *notify_callback;
 	void *notify_context;
 
+	/* Increased by one for each new struct mailbox. */
+	unsigned int generation_sequence;
+
 	/* Saved search results */
 	ARRAY_DEFINE(search_results, struct mail_search_result *);