[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-keywords.c, 1.6, 1.7 maildir-save.c, 1.72, 1.73 maildir-storage.c, 1.122, 1.123 maildir-storage.h, 1.51, 1.52 maildir-sync.c, 1.79, 1.80 maildir-uidlist.c, 1.52, 1.53

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


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

Modified Files:
	maildir-keywords.c maildir-save.c maildir-storage.c 
	maildir-storage.h maildir-sync.c maildir-uidlist.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: maildir-keywords.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-keywords.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- maildir-keywords.c	26 Feb 2006 11:24:39 -0000	1.6
+++ maildir-keywords.c	28 Jun 2006 13:10:51 -0000	1.7
@@ -25,7 +25,7 @@
 	char *path;
 
 	pool_t pool;
-	array_t ARRAY_DEFINE(list, const char *);
+	ARRAY_TYPE(keywords) list;
 	struct hash_table *hash; /* name -> idx+1 */
 
         struct dotlock_settings dotlock_settings;
@@ -39,8 +39,8 @@
 	struct maildir_keywords *mk;
 	struct mail_index *index;
 
-	const array_t *ARRAY_DEFINE_PTR(keywords, const char *);
-	array_t ARRAY_DEFINE(idx_to_chr, char);
+	const ARRAY_TYPE(keywords) *keywords;
+	ARRAY_DEFINE(idx_to_chr, char);
 	unsigned int chridx_to_idx[MAILDIR_MAX_KEYWORDS];
 };
 
@@ -139,7 +139,7 @@
 		new_name = p_strdup(mk->pool, p);
 		hash_insert(mk->hash, new_name, POINTER_CAST(idx + 1));
 
-		strp = array_idx_modifyable(&mk->list, idx);
+		strp = array_idx_modifiable(&mk->list, idx);
 		*strp = new_name;
 	}
 	i_stream_destroy(&input);
@@ -189,7 +189,7 @@
 	new_name = p_strdup(mk->pool, name);
 	hash_insert(mk->hash, new_name, POINTER_CAST(chridx + 1));
 
-	strp = array_idx_modifyable(&mk->list, chridx);
+	strp = array_idx_modifiable(&mk->list, chridx);
 	*strp = new_name;
 
 	mk->changed = TRUE;
@@ -370,7 +370,7 @@
 	char *chr_p;
 	int chridx;
 
-	chr_p = array_idx_modifyable(&ctx->idx_to_chr, idx);
+	chr_p = array_idx_modifiable(&ctx->idx_to_chr, idx);
 	if (*chr_p != '\0')
 		return *chr_p;
 

Index: maildir-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-save.c,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -d -r1.72 -r1.73
--- maildir-save.c	16 Jun 2006 09:40:40 -0000	1.72
+++ maildir-save.c	28 Jun 2006 13:10:51 -0000	1.73
@@ -44,7 +44,7 @@
 	struct maildir_filename *files, **files_tail;
 
 	buffer_t *keywords_buffer;
-	array_t ARRAY_DEFINE(keywords_array, unsigned int);
+	ARRAY_TYPE(keyword_indexes) keywords_array;
 
 	struct istream *input, *input2;
 	struct ostream *output;

Index: maildir-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- maildir-storage.c	26 Jun 2006 17:48:20 -0000	1.122
+++ maildir-storage.c	28 Jun 2006 13:10:52 -0000	1.123
@@ -762,7 +762,7 @@
 {
 	struct mailbox_list_context *ctx;
         struct mailbox_list *list;
-	array_t ARRAY_DEFINE(names_arr, const char *);
+	ARRAY_DEFINE(names_arr, const char *);
 	const char *oldpath, *newpath, *old_listname, *new_listname;
 	const char *const *names;
 	unsigned int i, count;

Index: maildir-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -d -r1.51 -r1.52
--- maildir-storage.h	16 Jun 2006 09:40:40 -0000	1.51
+++ maildir-storage.h	28 Jun 2006 13:10:52 -0000	1.52
@@ -154,12 +154,12 @@
 
 int maildir_filename_get_flags(struct maildir_keywords_sync_ctx *ctx,
 			       const char *fname, enum mail_flags *flags_r,
-			       array_t *keywords);
+			       ARRAY_TYPE(keyword_indexes) *keywords);
 struct maildir_keywords_sync_ctx *
 maildir_sync_get_keywords_sync_ctx(struct maildir_index_sync_context *ctx);
 const char *maildir_filename_set_flags(struct maildir_keywords_sync_ctx *ctx,
 				       const char *fname, enum mail_flags flags,
-				       array_t *keywords);
+				       ARRAY_TYPE(keyword_indexes) *keywords);
 
 unsigned int maildir_hash(const void *p);
 int maildir_cmp(const void *p1, const void *p2);

Index: maildir-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-sync.c,v
retrieving revision 1.79
retrieving revision 1.80
diff -u -d -r1.79 -r1.80
--- maildir-sync.c	27 Jun 2006 22:51:47 -0000	1.79
+++ maildir-sync.c	28 Jun 2006 13:10:52 -0000	1.80
@@ -214,7 +214,7 @@
         struct maildir_keywords_sync_ctx *keywords_sync_ctx;
 	struct mail_index_transaction *trans;
 
-	array_t ARRAY_DEFINE(sync_recs, struct mail_index_sync_rec);
+	ARRAY_DEFINE(sync_recs, struct mail_index_sync_rec);
 	uint32_t seq;
 	int dirty_state;
 };
@@ -227,9 +227,8 @@
 
 int maildir_filename_get_flags(struct maildir_keywords_sync_ctx *ctx,
 			       const char *fname, enum mail_flags *flags_r,
-                               array_t *keywords_r)
+                               ARRAY_TYPE(keyword_indexes) *keywords_r)
 {
-	ARRAY_SET_TYPE(keywords_r, unsigned int);
 	const char *info;
 
 	array_clear(keywords_r);
@@ -282,9 +281,9 @@
 
 static void
 maildir_filename_append_keywords(struct maildir_keywords_sync_ctx *ctx,
-				 array_t *keywords, string_t *str)
+				 ARRAY_TYPE(keyword_indexes) *keywords,
+				 string_t *str)
 {
-	ARRAY_SET_TYPE(keywords, unsigned int);
 	const unsigned int *indexes;
 	unsigned int i, count;
 	char chr;
@@ -299,7 +298,7 @@
 
 const char *maildir_filename_set_flags(struct maildir_keywords_sync_ctx *ctx,
 				       const char *fname, enum mail_flags flags,
-				       array_t *keywords)
+				       ARRAY_TYPE(keyword_indexes) *keywords)
 {
 	string_t *flags_str;
 	enum mail_flags flags_left;
@@ -402,7 +401,7 @@
 	const struct mail_index_sync_rec *recs;
 	const char *dir, *fname, *newfname, *newpath;
 	enum mail_flags flags;
-	array_t ARRAY_DEFINE(keywords, unsigned int);
+	ARRAY_TYPE(keyword_indexes) keywords;
 	unsigned int i, count;
 	uint8_t flags8;
 
@@ -418,7 +417,7 @@
 					 fname, &flags, &keywords);
 	flags8 = flags;
 
-	recs = array_get_modifyable(&ctx->sync_recs, &count);
+	recs = array_get_modifiable(&ctx->sync_recs, &count);
 	for (i = 0; i < count; i++) {
 		if (recs[i].uid1 != ctx->seq)
 			break;
@@ -473,7 +472,7 @@
 	uint32_t seq, uid;
 	bool expunged, flag_changed;
 
-	recs = array_get_modifyable(&ctx->sync_recs, &count);
+	recs = array_get_modifiable(&ctx->sync_recs, &count);
 	for (seq = recs[0].uid1; seq <= last_seq; seq++) {
 		expunged = flag_changed = FALSE;
 		for (i = 0; i < count; i++) {
@@ -514,7 +513,7 @@
 		for (i = count; i > 0; i--) {
 			if (++recs[i-1].uid1 > recs[i-1].uid2) {
 				array_delete(&ctx->sync_recs, i-1, 1);
-				recs = array_get_modifyable(&ctx->sync_recs,
+				recs = array_get_modifiable(&ctx->sync_recs,
 							    &count);
 				if (count == 0) {
 					/* all sync_recs committed */
@@ -937,8 +936,8 @@
         enum maildir_uidlist_rec_flag uflags;
 	const char *filename;
 	enum mail_flags flags;
-	array_t ARRAY_DEFINE(keywords, unsigned int);
-	array_t ARRAY_DEFINE(idx_keywords, unsigned int);
+	ARRAY_TYPE(keyword_indexes) keywords;
+	ARRAY_TYPE(keyword_indexes) idx_keywords;
 	uint32_t uid_validity, next_uid;
 	uint64_t value;
 	time_t old_new_sync_time;

Index: maildir-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-uidlist.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- maildir-uidlist.c	17 Jun 2006 13:55:30 -0000	1.52
+++ maildir-uidlist.c	28 Jun 2006 13:10:52 -0000	1.53
@@ -650,7 +650,7 @@
 	struct maildir_uidlist_rec **rec_p;
 	size_t i, size;
 
-	rec_p = buffer_get_modifyable_data(uidlist->record_buf, &size);
+	rec_p = buffer_get_modifiable_data(uidlist->record_buf, &size);
 	size /= sizeof(*rec_p);
 
 	if (nonsynced) {
@@ -844,7 +844,7 @@
 
 	i_assert(UIDLIST_IS_LOCKED(uidlist));
 
-	rec_p = buffer_get_modifyable_data(uidlist->record_buf, &size);
+	rec_p = buffer_get_modifiable_data(uidlist->record_buf, &size);
 	size /= sizeof(*rec_p);
 
 	/* sort new files and assign UIDs for them */
@@ -878,7 +878,7 @@
 	size_t size;
 
 	/* buffer is unsorted, sort it by UID */
-	rec_p = buffer_get_modifyable_data(ctx->record_buf, &size);
+	rec_p = buffer_get_modifiable_data(ctx->record_buf, &size);
 	size /= sizeof(*rec_p);
 	qsort(rec_p, size, sizeof(*rec_p), maildir_uid_cmp);
 



More information about the dovecot-cvs mailing list