[dovecot-cvs] dovecot/src/lib-storage/index/mbox mbox-save.c, 1.96, 1.97 mbox-sync-parse.c, 1.51, 1.52 mbox-sync-private.h, 1.56, 1.57 mbox-sync-rewrite.c, 1.64, 1.65 mbox-sync-update.c, 1.47, 1.48 mbox-sync.c, 1.182, 1.183

cras at dovecot.org cras at dovecot.org
Wed Jun 28 16:10:59 EEST 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/mbox
In directory talvi:/tmp/cvs-serv11200/src/lib-storage/index/mbox

Modified Files:
	mbox-save.c mbox-sync-parse.c mbox-sync-private.h 
	mbox-sync-rewrite.c mbox-sync-update.c mbox-sync.c 
Log Message:
Array API redesigned to work using unions. It now provides type safety
without having to enable DEBUG, as long as the compiler supports typeof().
Its API changed a bit. It now allows directly accessing the array contents,
although that's not necessarily recommended. Changed existing array usage to
be type safe in a bit more places. Removed array_t completely. Also did
s/modifyable/modifiable/.



Index: mbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-save.c,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -d -r1.96 -r1.97
--- mbox-save.c	17 Jun 2006 18:00:35 -0000	1.96
+++ mbox-save.c	28 Jun 2006 13:10:53 -0000	1.97
@@ -239,8 +239,7 @@
 {
 	unsigned char space[MBOX_HEADER_PADDING+1 +
 			    sizeof("Content-Length: \n")-1 + MAX_INT_STRLEN];
-	const array_t *keyword_names_list;
-	ARRAY_SET_TYPE(keyword_names_list, const char *);
+	const ARRAY_TYPE(keywords) *keyword_names_list;
 	const char *const *keyword_names;
 	unsigned int i, count, keyword_names_count;
 

Index: mbox-sync-parse.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-parse.c,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- mbox-sync-parse.c	17 Jun 2006 17:11:30 -0000	1.51
+++ mbox-sync-parse.c	28 Jun 2006 13:10:53 -0000	1.52
@@ -256,7 +256,7 @@
 static bool parse_x_keywords(struct mbox_sync_mail_context *ctx,
 			     struct message_header_line *hdr)
 {
-	array_t ARRAY_DEFINE(keyword_list, unsigned int);
+	ARRAY_TYPE(keyword_indexes) keyword_list;
 	const unsigned int *list;
 	string_t *keyword;
 	size_t keyword_start;

Index: mbox-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-private.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- mbox-sync-private.h	13 Jan 2006 20:26:37 -0000	1.56
+++ mbox-sync-private.h	28 Jun 2006 13:10:53 -0000	1.57
@@ -4,6 +4,8 @@
 #include "md5.h"
 #include "mail-index.h"
 
+ARRAY_DEFINE_TYPE(sync_recs, struct mail_index_sync_rec);
+
 enum mbox_sync_flags {
 	MBOX_SYNC_LAST_COMMIT	= 0x01,
 	MBOX_SYNC_HEADER	= 0x02,
@@ -43,7 +45,7 @@
 	uint32_t uid;
 	uint32_t idx_seq;
 
-	array_t ARRAY_DEFINE(keywords, unsigned int);
+	ARRAY_TYPE(keyword_indexes) keywords;
 	uint8_t flags;
 
 	unsigned int uid_broken:1;
@@ -111,8 +113,8 @@
 	uoff_t base_uid_last_offset;
 
 	/* mail state: */
-	array_t ARRAY_DEFINE(mails, struct mbox_sync_mail);
-	array_t ARRAY_DEFINE(syncs, struct mail_index_sync_rec);
+	ARRAY_DEFINE(mails, struct mbox_sync_mail);
+	ARRAY_TYPE(sync_recs) syncs;
 	struct mail_index_sync_rec sync_rec;
 
 	pool_t mail_keyword_pool;

Index: mbox-sync-rewrite.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-rewrite.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- mbox-sync-rewrite.c	24 Jun 2006 20:54:35 -0000	1.64
+++ mbox-sync-rewrite.c	28 Jun 2006 13:10:53 -0000	1.65
@@ -456,7 +456,7 @@
 	i_assert(extra_space < OFF_T_MAX);
 	i_assert(sync_ctx->mbox->mbox_lock_type == F_WRLCK);
 
-	mails = array_get_modifyable(&sync_ctx->mails, &count);
+	mails = array_get_modifiable(&sync_ctx->mails, &count);
 	i_assert(count == last_seq - first_seq + 1);
 
 	/* if there's expunges in mails[], we would get more correct balancing

Index: mbox-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync-update.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- mbox-sync-update.c	24 Jun 2006 20:53:37 -0000	1.47
+++ mbox-sync-update.c	28 Jun 2006 13:10:53 -0000	1.48
@@ -88,7 +88,7 @@
 	}
 
 	/* how many bytes do we have now? */
-	data = buffer_get_modifyable_data(ctx->header, &size);
+	data = buffer_get_modifiable_data(ctx->header, &size);
 	for (have = 0; pos < size; pos++) {
 		if (data[pos] == '\n' || data[pos] == '\r')
 			break;
@@ -119,10 +119,10 @@
 	ctx->mail.flags ^= MBOX_NONRECENT_KLUDGE;
 }
 
-static void keywords_append(struct mbox_sync_context *sync_ctx, string_t *dest,
-			    const array_t *keyword_indexes_arr)
+static void
+keywords_append(struct mbox_sync_context *sync_ctx, string_t *dest,
+		const ARRAY_TYPE(keyword_indexes) *keyword_indexes_arr)
 {
-	ARRAY_SET_TYPE(keyword_indexes_arr, unsigned int);
 	const char *const *keyword_names;
 	const unsigned int *keyword_indexes;
 	unsigned int i, idx_count, keywords_count;
@@ -444,8 +444,7 @@
 		array_append_array(&ctx->mail.keywords,
 				   &mail->keywords);
 		mbox_sync_update_xkeywords(ctx);
-	} else if (!buffer_cmp(ctx->mail.keywords.buffer,
-			       mail->keywords.buffer)) {
+	} else if (!array_cmp(&ctx->mail.keywords, &mail->keywords)) {
 		/* keywords changed. */
 		array_clear(&ctx->mail.keywords);
 		array_append_array(&ctx->mail.keywords,

Index: mbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/mbox/mbox-sync.c,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- mbox-sync.c	17 Jun 2006 20:03:18 -0000	1.182
+++ mbox-sync.c	28 Jun 2006 13:10:53 -0000	1.183
@@ -75,13 +75,13 @@
 	return 0;
 }
 
-static void mbox_sync_array_delete_to(array_t *syncs_arr, uint32_t last_uid)
+static void mbox_sync_array_delete_to(ARRAY_TYPE(sync_recs) *syncs_arr,
+				      uint32_t last_uid)
 {
-	ARRAY_SET_TYPE(syncs_arr, struct mail_index_sync_rec);
 	struct mail_index_sync_rec *syncs;
 	unsigned int src, dest, count;
 
-	syncs = array_get_modifyable(syncs_arr, &count);
+	syncs = array_get_modifiable(syncs_arr, &count);
 
 	for (src = dest = 0; src < count; src++) {
 		i_assert(last_uid >= syncs[src].uid1);
@@ -134,9 +134,8 @@
 	return 1;
 }
 
-static bool mbox_sync_buf_have_expunges(array_t *syncs_arr)
+static bool mbox_sync_buf_have_expunges(ARRAY_TYPE(sync_recs) *syncs_arr)
 {
-	ARRAY_SET_TYPE(syncs_arr, struct mail_index_sync_rec);
 	const struct mail_index_sync_rec *syncs;
 	unsigned int i, count;
 



More information about the dovecot-cvs mailing list