[dovecot-cvs] dovecot/src/lib-storage/index/dbox dbox-keywords.c, 1.3, 1.4 dbox-save.c, 1.15, 1.16 dbox-storage.h, 1.12, 1.13 dbox-sync-expunge.c, 1.16, 1.17 dbox-sync-full.c, 1.7, 1.8 dbox-sync.c, 1.18, 1.19 dbox-sync.h, 1.6, 1.7 dbox-uidlist.c, 1.32, 1.33 dbox-uidlist.h, 1.6, 1.7

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


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

Modified Files:
	dbox-keywords.c dbox-save.c dbox-storage.h dbox-sync-expunge.c 
	dbox-sync-full.c dbox-sync.c dbox-sync.h dbox-uidlist.c 
	dbox-uidlist.h 
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: dbox-keywords.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-keywords.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- dbox-keywords.c	30 May 2006 08:22:29 -0000	1.3
+++ dbox-keywords.c	28 Jun 2006 13:10:50 -0000	1.4
@@ -59,7 +59,7 @@
 		kw.file_idx = idx;
 
 		/* look up the position where to insert it */
-		map = array_get_modifyable(&file->idx_file_keywords, &count);
+		map = array_get_modifiable(&file->idx_file_keywords, &count);
 		pos = idx == 0 ? map :
 			bsearch_insert_pos(&kw, map, count, sizeof(*map),
 					   dbox_keyword_map_compare);
@@ -118,8 +118,7 @@
 			      const struct seq_range *idx_range,
 			      unsigned int count)
 {
-	const array_t *idx_keywords;
-	ARRAY_SET_TYPE(idx_keywords, const char *);
+	const ARRAY_TYPE(keywords) *idx_keywords;
 	string_t *keyword_str;
 	const char *const *idx_keyword_names;
 	unsigned int i, idx_keyword_count, new_pos;

Index: dbox-save.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-save.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dbox-save.c	15 Jun 2006 10:33:55 -0000	1.15
+++ dbox-save.c	28 Jun 2006 13:10:50 -0000	1.16
@@ -43,7 +43,7 @@
 		       const struct mail_keywords *keywords,
 		       buffer_t *file_keywords)
 {
-	array_t ARRAY_DEFINE(new_keywords, struct seq_range);
+	ARRAY_TYPE(seq_range) new_keywords;
 	const struct seq_range *range;
 	unsigned int i, count, file_idx;
 	int ret = 0;
@@ -184,7 +184,7 @@
 		size_t size;
 
 		keyword_string =
-			buffer_get_modifyable_data(file_keywords, &size);
+			buffer_get_modifiable_data(file_keywords, &size);
 
 		/* string should be filled with NULs and '1' now.
 		   Change NULs to '0'. */

Index: dbox-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-storage.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- dbox-storage.h	12 Jun 2006 08:24:44 -0000	1.12
+++ dbox-storage.h	28 Jun 2006 13:10:50 -0000	1.13
@@ -47,9 +47,9 @@
 	unsigned char *seeked_keywords;
 
 	/* Keywords list, sorted by index_idx. */
-	array_t ARRAY_DEFINE(idx_file_keywords, struct keyword_map);
+	ARRAY_DEFINE(idx_file_keywords, struct keyword_map);
 	/* idx -> index_idx array */
-	array_t ARRAY_DEFINE(file_idx_keywords, unsigned int);
+	ARRAY_DEFINE(file_idx_keywords, unsigned int);
 };
 
 struct dbox_mailbox {

Index: dbox-sync-expunge.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-expunge.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- dbox-sync-expunge.c	12 Jun 2006 08:24:44 -0000	1.16
+++ dbox-sync-expunge.c	28 Jun 2006 13:10:50 -0000	1.17
@@ -306,7 +306,7 @@
 	/* find the first non-expunged mail */
 	first_expunged_uid = exp_uid1;
 	seen_expunges = FALSE; skipped_expunges = FALSE; uid = 0;
-	range = array_get_modifyable(&entry->uid_list, &count);
+	range = array_get_modifiable(&entry->uid_list, &count);
 	for (i = 0; i < count; i++) {
 		uid = range[i].seq1;
 

Index: dbox-sync-full.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync-full.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- dbox-sync-full.c	12 Jun 2006 08:24:44 -0000	1.7
+++ dbox-sync-full.c	28 Jun 2006 13:10:50 -0000	1.8
@@ -16,13 +16,11 @@
 
 static int
 dbox_mail_get_keywords(struct dbox_mailbox *mbox, struct dbox_file *file,
-		       array_t *keywords)
+		       ARRAY_TYPE(keyword_indexes) *keywords)
 {
 	const unsigned int *map;
 	unsigned int i, count;
 
-	ARRAY_SET_TYPE(keywords, unsigned int);
-
 	if (!array_is_created(&file->file_idx_keywords)) {
 		if (dbox_file_read_keywords(mbox, file) < 0)
 			return -1;
@@ -43,7 +41,7 @@
 	const struct dbox_mail_header *hdr = &mbox->file->seeked_mail_header;
 	enum mail_flags flags;
         struct mail_keywords *keywords;
-	array_t ARRAY_DEFINE(keywords_arr, unsigned int);
+	ARRAY_TYPE(keyword_indexes) keywords_arr;
 	uint32_t seq;
 	uint64_t hdr_offset = mbox->file->seeked_offset;
 

Index: dbox-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- dbox-sync.c	12 Jun 2006 08:24:44 -0000	1.18
+++ dbox-sync.c	28 Jun 2006 13:10:50 -0000	1.19
@@ -312,7 +312,7 @@
 			    const struct dbox_sync_file_entry *entry,
 			    unsigned int i)
 {
-	array_t ARRAY_DEFINE(keywords, struct seq_range);
+	ARRAY_TYPE(seq_range) keywords;
 	const struct dbox_sync_rec *sync_recs;
 	const struct seq_range *range;
 	unsigned int count, file_idx, keyword_idx;

Index: dbox-sync.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-sync.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dbox-sync.h	3 May 2006 22:02:55 -0000	1.6
+++ dbox-sync.h	28 Jun 2006 13:10:50 -0000	1.7
@@ -1,6 +1,7 @@
 #ifndef __DBOX_SYNC_H
 #define __DBOX_SYNC_H
 
+#include "seq-range-array.h"
 #include "mail-index.h"
 #include "mail-storage.h"
 
@@ -26,7 +27,7 @@
 struct dbox_sync_file_entry {
 	uint32_t file_seq;
 
-	array_t ARRAY_DEFINE(sync_recs, struct dbox_sync_rec);
+	ARRAY_DEFINE(sync_recs, struct dbox_sync_rec);
 };
 
 struct dbox_sync_context {
@@ -38,13 +39,13 @@
 
 	pool_t pool;
 	struct hash_table *syncs; /* struct dbox_sync_file_entry */
-	array_t ARRAY_DEFINE(added_file_seqs, uint32_t);
+	ARRAY_DEFINE(added_file_seqs, uint32_t);
 
 	uint32_t dotlock_failed_file_seq;
 
 	/* full sync: */
 	uint32_t mail_index_next_uid;
-	array_t ARRAY_DEFINE(exists, struct seq_range);
+	ARRAY_TYPE(seq_range) exists;
 };
 
 int dbox_sync(struct dbox_mailbox *mbox, bool force);

Index: dbox-uidlist.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- dbox-uidlist.c	16 Jun 2006 09:52:58 -0000	1.32
+++ dbox-uidlist.c	28 Jun 2006 13:10:50 -0000	1.33
@@ -34,7 +34,7 @@
 	ino_t ino;
 
 	struct dotlock *dotlock;
-	array_t ARRAY_DEFINE(seqs, unsigned int);
+	ARRAY_DEFINE(seqs, unsigned int);
 };
 
 struct dbox_uidlist {
@@ -54,7 +54,7 @@
 	uint32_t file_seq_highwater;
 
 	pool_t entry_pool;
-	array_t ARRAY_DEFINE(entries, struct dbox_uidlist_entry *);
+	ARRAY_DEFINE(entries, struct dbox_uidlist_entry *);
 
 	unsigned int appending:1;
 	unsigned int need_full_rewrite:1;
@@ -67,7 +67,7 @@
 	time_t min_usable_timestamp;
 	unsigned int mail_count;
 
-	array_t ARRAY_DEFINE(files, struct dbox_save_file *);
+	ARRAY_DEFINE(files, struct dbox_save_file *);
 	unsigned int open_fds;
 
 	unsigned int locked:1;
@@ -133,13 +133,12 @@
 	i_free(uidlist);
 }
 
-static int uidlist_merge(array_t *uid_list, const struct seq_range *seqs)
+static int uidlist_merge(ARRAY_TYPE(seq_range) *uid_list, const struct seq_range *seqs)
 {
-	ARRAY_SET_TYPE(uid_list, struct seq_range);
 	struct seq_range *range;
 	unsigned int count;
 
-	range = array_get_modifyable(uid_list, &count);
+	range = array_get_modifiable(uid_list, &count);
 	i_assert(count > 0);
 
 	if (seqs->seq1 <= range[count-1].seq2)
@@ -182,7 +181,7 @@
 
 	dbox_uidlist_update_last_uid(uidlist, src_entry);
 
-	entries = array_get_modifyable(&uidlist->entries, &count);
+	entries = array_get_modifiable(&uidlist->entries, &count);
 	if (count == 0 || src_entry->file_seq > entries[count-1]->file_seq) {
 		/* append new file sequence */
 		idx = count;

Index: dbox-uidlist.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/dbox/dbox-uidlist.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dbox-uidlist.h	8 Jun 2006 18:21:12 -0000	1.6
+++ dbox-uidlist.h	28 Jun 2006 13:10:51 -0000	1.7
@@ -1,12 +1,14 @@
 #ifndef __DBOX_UIDLIST_H
 #define __DBOX_UIDLIST_H
 
+#include "seq-range-array.h"
+
 struct dbox_file;
 struct dbox_mailbox;
 struct dbox_uidlist_sync_ctx;
 
 struct dbox_uidlist_entry {
-	array_t ARRAY_DEFINE(uid_list, struct seq_range);
+	ARRAY_TYPE(seq_range) uid_list;
 
 	uint32_t file_seq;
 	/* file creation timestamp. used for rotation checks. */



More information about the dovecot-cvs mailing list