[dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.42, 1.43 mail-cache-lookup.c, 1.33, 1.34 mail-cache-private.h, 1.29, 1.30 mail-cache-transaction.c, 1.50, 1.51 mail-index-private.h, 1.70, 1.71 mail-index-sync-ext.c, 1.18, 1.19 mail-index-sync-private.h, 1.30, 1.31 mail-index-sync-update.c, 1.99, 1.100 mail-index-sync.c, 1.74, 1.75 mail-index-transaction-private.h, 1.29, 1.30 mail-index-transaction-view.c, 1.17, 1.18 mail-index-transaction.c, 1.76, 1.77 mail-index-view-private.h, 1.23, 1.24 mail-index-view-sync.c, 1.53, 1.54 mail-index-view.c, 1.45, 1.46 mail-index.c, 1.235, 1.236 mail-index.h, 1.158, 1.159 mail-transaction-log-append.c, 1.18, 1.19

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


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

Modified Files:
	mail-cache-compress.c mail-cache-lookup.c mail-cache-private.h 
	mail-cache-transaction.c mail-index-private.h 
	mail-index-sync-ext.c mail-index-sync-private.h 
	mail-index-sync-update.c mail-index-sync.c 
	mail-index-transaction-private.h mail-index-transaction-view.c 
	mail-index-transaction.c mail-index-view-private.h 
	mail-index-view-sync.c mail-index-view.c mail-index.c 
	mail-index.h mail-transaction-log-append.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: mail-cache-compress.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-compress.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- mail-cache-compress.c	3 May 2006 20:07:13 -0000	1.42
+++ mail-cache-compress.c	28 Jun 2006 13:10:38 -0000	1.43
@@ -28,7 +28,7 @@
 	unsigned int i, buf_data_size;
 	size_t pos, buf_size;
 
-	buf_data = buffer_get_modifyable_data(buffer, &buf_size);
+	buf_data = buffer_get_modifiable_data(buffer, &buf_size);
 	for (pos = sizeof(struct mail_cache_record); pos < buf_size; ) {
 		buf_field = *((uint32_t *)PTR_OFFSET(buf_data, pos));
 		pos += sizeof(uint32_t);
@@ -165,7 +165,7 @@
 		buffer_set_used_size(ctx.buffer, 0);
 
 		if (++ctx.field_seen_value == 0) {
-			memset(buffer_get_modifyable_data(ctx.field_seen, NULL),
+			memset(buffer_get_modifiable_data(ctx.field_seen, NULL),
 			       0, buffer_get_size(ctx.field_seen));
 			ctx.field_seen_value++;
 		}

Index: mail-cache-lookup.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-lookup.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- mail-cache-lookup.c	13 Jan 2006 20:26:13 -0000	1.33
+++ mail-cache-lookup.c	28 Jun 2006 13:10:38 -0000	1.34
@@ -248,7 +248,7 @@
 
 	if (++view->cached_exists_value == 0) {
 		/* wrapped, we'll have to clear the buffer */
-		memset(buffer_get_modifyable_data(view->cached_exists_buf,
+		memset(buffer_get_modifiable_data(view->cached_exists_buf,
 						  NULL), 0,
 		       buffer_get_size(view->cached_exists_buf));
 		view->cached_exists_value++;
@@ -466,7 +466,7 @@
 		buffer_write(buf, fields[i], &one, 1);
                 ctx.fields[i] = fields[i];
 	}
-	ctx.fields_found = buffer_get_modifyable_data(buf, NULL);
+	ctx.fields_found = buffer_get_modifiable_data(buf, NULL);
 
 	ctx.data = buffer_create_dynamic(pool_datastack_create(), 256);
 
@@ -486,7 +486,7 @@
 		}
 	}
 
-	data = buffer_get_modifyable_data(ctx.data, &size);
+	data = buffer_get_modifiable_data(ctx.data, &size);
 	size /= sizeof(*data);
 	qsort(data, size, sizeof(*data), header_lookup_data_cmp);
 

Index: mail-cache-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-private.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- mail-cache-private.h	3 May 2006 20:07:13 -0000	1.29
+++ mail-cache-private.h	28 Jun 2006 13:10:38 -0000	1.30
@@ -160,7 +160,7 @@
 	uint32_t trans_seq1, trans_seq2;
 
 	/* temporary array, just to avoid mallocs. */
-	array_t ARRAY_DEFINE(tmp_offsets, uint32_t);
+	ARRAY_DEFINE(tmp_offsets, uint32_t);
 
 	/* if cached_exists_buf[field] == cached_exists_value, it's cached.
 	   this allows us to avoid constantly clearing the whole buffer.

Index: mail-cache-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- mail-cache-transaction.c	8 May 2006 12:48:51 -0000	1.50
+++ mail-cache-transaction.c	28 Jun 2006 13:10:38 -0000	1.51
@@ -28,17 +28,19 @@
 	uint32_t cache_file_seq;
 
 	buffer_t *cache_data;
-	array_t ARRAY_DEFINE(cache_data_seq, uint32_t);
+	ARRAY_DEFINE(cache_data_seq, uint32_t);
 	uint32_t prev_seq;
 	size_t prev_pos;
 
-        array_t ARRAY_DEFINE(reservations, struct mail_cache_reservation);
+        ARRAY_DEFINE(reservations, struct mail_cache_reservation);
 	uint32_t reserved_space_offset, reserved_space;
 	uint32_t last_grow_size;
 
 	unsigned int changes:1;
 };
 
+ARRAY_DEFINE_TYPE(uint32_t, uint32_t);
+
 static int mail_cache_link_unlocked(struct mail_cache *cache,
 				    uint32_t old_offset, uint32_t new_offset);
 
@@ -255,7 +257,7 @@
 		/* grow reservation. it's probably the last one in the buffer,
 		   but it's not guarateed because we might have used holes
 		   as well */
-		reservations = array_get_modifyable(&ctx->reservations, &count);
+		reservations = array_get_modifiable(&ctx->reservations, &count);
 
 		do {
 			i_assert(count > 0);
@@ -537,7 +539,7 @@
 
 	if (ctx->prev_seq != 0) {
 		/* fix record size */
-		data = buffer_get_modifyable_data(ctx->cache_data, &size);
+		data = buffer_get_modifiable_data(ctx->cache_data, &size);
 		rec = PTR_OFFSET(data, ctx->prev_pos);
 		rec->size = size - ctx->prev_pos;
 		i_assert(rec->size != 0);
@@ -803,9 +805,8 @@
 	return 0;
 }
 
-static bool find_offset(array_t *array, uint32_t offset)
+static bool find_offset(ARRAY_TYPE(uint32_t) *array, uint32_t offset)
 {
-	ARRAY_SET_TYPE(array, uint32_t);
 	const uint32_t *offsets;
 	unsigned int i, count;
 
@@ -820,7 +821,7 @@
 int mail_cache_delete(struct mail_cache *cache, uint32_t offset)
 {
 	const struct mail_cache_record *cache_rec;
-	array_t ARRAY_DEFINE(tmp_offsets, uint32_t);
+	ARRAY_TYPE(uint32_t) tmp_offsets;
 
 	i_assert(cache->locked);
 

Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- mail-index-private.h	30 May 2006 08:36:11 -0000	1.70
+++ mail-index-private.h	28 Jun 2006 13:10:38 -0000	1.71
@@ -39,6 +39,8 @@
 				      const void *new_data, void **context);
 typedef void mail_index_sync_lost_handler_t(struct mail_index *index);
 
+ARRAY_DEFINE_TYPE(seq_array, uint32_t);
+
 #define MAIL_INDEX_HEADER_SIZE_ALIGN(size) \
 	(((size) + 7) & ~7)
 
@@ -106,8 +108,8 @@
 	unsigned int records_count;
 
 	pool_t extension_pool;
-	array_t ARRAY_DEFINE(extensions, struct mail_index_ext);
-	array_t ARRAY_DEFINE(ext_id_map, uint32_t); /* index -> file */
+	ARRAY_DEFINE(extensions, struct mail_index_ext);
+	ARRAY_DEFINE(ext_id_map, uint32_t); /* index -> file */
 
 	void *mmap_base;
 	size_t mmap_size, mmap_used_size;
@@ -115,7 +117,7 @@
 	buffer_t *buffer;
 	buffer_t *hdr_copy_buf;
 
-	array_t ARRAY_DEFINE(keyword_idx_map, unsigned int); /* file -> index */
+	ARRAY_DEFINE(keyword_idx_map, unsigned int); /* file -> index */
 
 	/* If write_to_disk=TRUE and write_atomic=FALSE, these sequences
 	   specify the range that needs to be written. Header should always
@@ -136,10 +138,9 @@
 	gid_t gid;
 
 	pool_t extension_pool;
-	array_t ARRAY_DEFINE(extensions, struct mail_index_registered_ext);
+	ARRAY_DEFINE(extensions, struct mail_index_registered_ext);
 
-	array_t ARRAY_DEFINE(sync_lost_handlers,
-			     mail_index_sync_lost_handler_t *);
+	ARRAY_DEFINE(sync_lost_handlers, mail_index_sync_lost_handler_t *);
 
 	char *filepath;
 	int fd;
@@ -160,12 +161,15 @@
 	uoff_t sync_log_file_offset;
 
 	pool_t keywords_pool;
-	array_t ARRAY_DEFINE(keywords, const char *);
+	ARRAY_TYPE(keywords) keywords;
 	struct hash_table *keywords_hash; /* name -> idx */
 
 	uint32_t keywords_ext_id;
 	unsigned int last_grow_count;
 
+	/* Module-specific contexts. See mail_index_module_id. */
+	ARRAY_DEFINE(module_contexts, void);
+
 	char *error;
 	unsigned int nodiskspace:1;
 	unsigned int index_lock_timeout:1;

Index: mail-index-sync-ext.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-ext.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mail-index-sync-ext.c	30 May 2006 08:34:23 -0000	1.18
+++ mail-index-sync-ext.c	28 Jun 2006 13:10:38 -0000	1.19
@@ -34,7 +34,7 @@
 	rext = array_get(&ctx->view->index->extensions, &rext_count);
 	ext = array_get(&ctx->view->map->extensions, &ext_count);
 	id_map = array_get(&ctx->view->map->ext_id_map, &id_map_count);
-	contexts = array_get_modifyable(&ctx->extra_contexts, &context_count);
+	contexts = array_get_modifiable(&ctx->extra_contexts, &context_count);
 
 	i_assert(id_map_count <= rext_count);
 
@@ -91,7 +91,7 @@
 	}
 
 	/* fill the context array with NULLs */
-	(void)array_idx_modifyable(&ctx->extra_contexts, count - 1);
+	(void)array_idx_modifiable(&ctx->extra_contexts, count - 1);
 	ctx->expunge_handlers_set = FALSE;
 }
 
@@ -115,7 +115,7 @@
 
 	/* extra_contexts[] is ordered by map->extensions. */
 	extra_contexts =
-		array_get_modifyable(&ctx->extra_contexts, &context_count);
+		array_get_modifiable(&ctx->extra_contexts, &context_count);
 	i_assert(count <= context_count);
 
 	for (i = 0; i < count; i++) {
@@ -141,7 +141,7 @@
 		MAIL_INDEX_HEADER_SIZE_ALIGN(sizeof(*ext_hdr) +
 					     strlen(ext->name));
 
-	hdr_base = buffer_get_modifyable_data(map->hdr_copy_buf, NULL);
+	hdr_base = buffer_get_modifiable_data(map->hdr_copy_buf, NULL);
 	ext_hdr = PTR_OFFSET(hdr_base, offset);
 	i_assert(memcmp((char *)(ext_hdr + 1),
 			ext->name, strlen(ext->name)) == 0);
@@ -167,7 +167,7 @@
 	const void *src;
 
 	t_push();
-	ext = array_get_modifyable(&map->extensions, &count);
+	ext = array_get_modifiable(&map->extensions, &count);
 
 	/* @UNSAFE */
 	old_offsets = t_new(uint16_t, count);
@@ -256,7 +256,7 @@
 		buffer_append_zero(new_map->buffer, space);
 	}
 
-	new_map->records = buffer_get_modifyable_data(new_map->buffer, NULL);
+	new_map->records = buffer_get_modifiable_data(new_map->buffer, NULL);
 	new_map->records_count = old_records_count;
 	i_assert(new_map->records_count == new_map->hdr.messages_count);
 
@@ -280,7 +280,7 @@
 	uint32_t old_size, new_size, old_record_size;
 	bool modified = FALSE;
 
-	ext = array_idx_modifyable(&map->extensions, ext_id);
+	ext = array_idx_modifiable(&map->extensions, ext_id);
 
 	old_size = MAIL_INDEX_HEADER_SIZE_ALIGN(ext->hdr_size);
 	new_size = MAIL_INDEX_HEADER_SIZE_ALIGN(u->hdr_size);
@@ -324,7 +324,7 @@
 		unsigned i, count = array_count(&map->extensions);
 		ssize_t diff = (ssize_t)new_size - (ssize_t)old_size;
 
-		ext = array_idx_modifyable(&map->extensions, 0);
+		ext = array_idx_modifiable(&map->extensions, 0);
 		for (i = ext_id + 1; i < count; i++)
 			ext[i].hdr_offset += diff;
 	}
@@ -468,7 +468,7 @@
 		mail_index_sync_replace_map(ctx, map);
 	}
 
-	ext = array_idx_modifyable(&map->extensions, ctx->cur_ext_id);
+	ext = array_idx_modifiable(&map->extensions, ctx->cur_ext_id);
 	ext->reset_id = u->new_reset_id;
 
 	memset(buffer_get_space_unsafe(map->hdr_copy_buf, ext->hdr_offset,
@@ -543,7 +543,7 @@
 	   current synchronization type (index/view) */
 	if ((rext->sync_handler.type & ctx->type) != 0) {
 		void **extra_context =
-			array_idx_modifyable(&ctx->extra_contexts,
+			array_idx_modifiable(&ctx->extra_contexts,
 					     ctx->cur_ext_id);
 		ret = rext->sync_handler.callback(ctx, seq, old_data, u + 1,
 						  extra_context);

Index: mail-index-sync-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-private.h,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- mail-index-sync-private.h	30 May 2006 08:31:20 -0000	1.30
+++ mail-index-sync-private.h	28 Jun 2006 13:10:38 -0000	1.31
@@ -3,6 +3,11 @@
 
 #include "mail-transaction-log.h"
 
+struct uid_range {
+	uint32_t uid1, uid2;
+};
+ARRAY_DEFINE_TYPE(uid_range, struct uid_range);
+
 struct mail_index_sync_ctx {
 	struct mail_index *index;
 	struct mail_index_view *view;
@@ -11,7 +16,7 @@
 	const struct mail_transaction_header *hdr;
 	const void *data;
 
-	array_t ARRAY_DEFINE(sync_list, struct mail_index_sync_list);
+	ARRAY_DEFINE(sync_list, struct mail_index_sync_list);
 	uint32_t next_uid;
 
 	uint32_t append_uid_first, append_uid_last;
@@ -24,7 +29,7 @@
 };
 
 struct mail_index_sync_list {
-	const array_t *ARRAY_DEFINE_PTR(array, struct uid_range);
+	const ARRAY_TYPE(uid_range) *array;
 	unsigned int idx;
 	unsigned int keyword_idx:31;
 	unsigned int keyword_remove:1;
@@ -40,10 +45,8 @@
 	struct mail_index_view *view;
 	uint32_t cur_ext_id;
 
-	array_t ARRAY_DEFINE(expunge_handlers,
-			     struct mail_index_expunge_handler);
-
-	array_t ARRAY_DEFINE(extra_contexts, void *);
+	ARRAY_DEFINE(expunge_handlers, struct mail_index_expunge_handler);
+	ARRAY_DEFINE(extra_contexts, void *);
 
         enum mail_index_sync_handler_type type;
 

Index: mail-index-sync-update.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync-update.c,v
retrieving revision 1.99
retrieving revision 1.100
diff -u -d -r1.99 -r1.100
--- mail-index-sync-update.c	30 May 2006 08:36:43 -0000	1.99
+++ mail-index-sync-update.c	28 Jun 2006 13:10:38 -0000	1.100
@@ -213,7 +213,7 @@
 	if (map->buffer != NULL) {
 		buffer_set_used_size(map->buffer, map->records_count *
 				     map->hdr.record_size);
-		map->records = buffer_get_modifyable_data(map->buffer, NULL);
+		map->records = buffer_get_modifiable_data(map->buffer, NULL);
 	}
 	return 1;
 }
@@ -247,7 +247,7 @@
 			 buffer_get_used_size(map->buffer));
 		dest = buffer_append_space_unsafe(map->buffer,
 						  map->hdr.record_size);
-		map->records = buffer_get_modifyable_data(map->buffer, NULL);
+		map->records = buffer_get_modifiable_data(map->buffer, NULL);
 	} else {
 		i_assert((map->records_count+1) * map->hdr.record_size <=
 			 map->mmap_size);

Index: mail-index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-sync.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- mail-index-sync.c	30 May 2006 08:36:11 -0000	1.74
+++ mail-index-sync.c	28 Jun 2006 13:10:38 -0000	1.75
@@ -12,10 +12,6 @@
 
 #include <stdlib.h>
 
-struct uid_range {
-	uint32_t uid1, uid2;
-};
-
 static void mail_index_sync_add_expunge(struct mail_index_sync_ctx *ctx)
 {
 	const struct mail_transaction_expunge *e = ctx->data;
@@ -224,18 +220,18 @@
 
 	if (array_is_created(&ctx->trans->expunges)) {
 		synclist = array_append_space(&ctx->sync_list);
-		synclist->array = &ctx->trans->expunges;
+		synclist->array = (void *)&ctx->trans->expunges;
 	}
 
 	if (array_is_created(&ctx->trans->updates)) {
 		synclist = array_append_space(&ctx->sync_list);
-		synclist->array = &ctx->trans->updates;
+		synclist->array = (void *)&ctx->trans->updates;
 	}
 
 	/* we must return resets before keyword additions or they get lost */
 	if (array_is_created(&ctx->trans->keyword_resets)) {
 		synclist = array_append_space(&ctx->sync_list);
-		synclist->array = &ctx->trans->keyword_resets;
+		synclist->array = (void *)&ctx->trans->keyword_resets;
 	}
 
 	keyword_updates = keyword_count == 0 ? NULL :
@@ -243,12 +239,13 @@
 	for (i = 0; i < keyword_count; i++) {
 		if (array_is_created(&keyword_updates[i].add_seq)) {
 			synclist = array_append_space(&ctx->sync_list);
-			synclist->array = &keyword_updates[i].add_seq;
+			synclist->array = (void *)&keyword_updates[i].add_seq;
 			synclist->keyword_idx = i;
 		}
 		if (array_is_created(&keyword_updates[i].remove_seq)) {
 			synclist = array_append_space(&ctx->sync_list);
-			synclist->array = &keyword_updates[i].remove_seq;
+			synclist->array =
+				(void *)&keyword_updates[i].remove_seq;
 			synclist->keyword_idx = i;
 			synclist->keyword_remove = TRUE;
 		}
@@ -536,7 +533,7 @@
 	/* FIXME: replace with a priority queue so we don't have to go
 	   through the whole list constantly. and remember to make sure that
 	   keyword resets are sent before adds! */
-	sync_list = array_get_modifyable(&ctx->sync_list, &count);
+	sync_list = array_get_modifiable(&ctx->sync_list, &count);
 	for (i = 0; i < count; i++) {
 		if (!array_is_created(sync_list[i].array) ||
 		    sync_list[i].idx == array_count(sync_list[i].array))
@@ -570,13 +567,13 @@
 		uid_range = array_idx(sync_list[i].array, sync_list[i].idx);
 	}
 
-	if (sync_list[i].array == &ctx->trans->expunges) {
+	if (sync_list[i].array == (void *)&ctx->trans->expunges) {
 		mail_index_sync_get_expunge(sync_rec,
 			(const struct mail_transaction_expunge *)uid_range);
-	} else if (sync_list[i].array == &ctx->trans->updates) {
+	} else if (sync_list[i].array == (void *)&ctx->trans->updates) {
 		mail_index_sync_get_update(sync_rec,
 			(const struct mail_transaction_flag_update *)uid_range);
-	} else if (sync_list[i].array == &ctx->trans->keyword_resets) {
+	} else if (sync_list[i].array == (void *)&ctx->trans->keyword_resets) {
 		mail_index_sync_get_keyword_reset(sync_rec, uid_range);
 	} else {
 		mail_index_sync_get_keyword_update(sync_rec, uid_range,
@@ -613,7 +610,7 @@
 
 	ctx->next_uid = 0;
 
-	sync_list = array_get_modifyable(&ctx->sync_list, &count);
+	sync_list = array_get_modifiable(&ctx->sync_list, &count);
 	for (i = 0; i < count; i++)
 		sync_list[i].idx = 0;
 }
@@ -699,9 +696,8 @@
 }
 
 bool mail_index_sync_keywords_apply(const struct mail_index_sync_rec *sync_rec,
-				    array_t *keywords)
+				    ARRAY_TYPE(keyword_indexes) *keywords)
 {
-	ARRAY_SET_TYPE(keywords, unsigned int);
 	const unsigned int *keyword_indexes;
 	unsigned int idx = sync_rec->keyword_idx;
 	unsigned int i, count;

Index: mail-index-transaction-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction-private.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- mail-index-transaction-private.h	15 Jan 2006 00:11:36 -0000	1.29
+++ mail-index-transaction-private.h	28 Jun 2006 13:10:38 -0000	1.30
@@ -1,22 +1,23 @@
 #ifndef __MAIL_INDEX_TRANSACTION_PRIVATE_H
 #define __MAIL_INDEX_TRANSACTION_PRIVATE_H
 
+#include "seq-range-array.h"
 #include "mail-transaction-log.h"
 
 struct mail_index_transaction_keyword_update {
-	array_t ARRAY_DEFINE(add_seq, struct seq_range);
-	array_t ARRAY_DEFINE(remove_seq, struct seq_range);
+	ARRAY_TYPE(seq_range) add_seq;
+	ARRAY_TYPE(seq_range) remove_seq;
 };
 
 struct mail_index_transaction {
 	int refcount;
 	struct mail_index_view *view;
 
-        array_t ARRAY_DEFINE(appends, struct mail_index_record);
+        ARRAY_DEFINE(appends, struct mail_index_record);
 	uint32_t first_new_seq, last_new_seq;
 
-	array_t ARRAY_DEFINE(expunges, struct mail_transaction_expunge);
-	array_t ARRAY_DEFINE(updates, struct mail_transaction_flag_update);
+	ARRAY_TYPE(seq_range) expunges;
+	ARRAY_DEFINE(updates, struct mail_transaction_flag_update);
 	size_t last_update_idx;
 
 	unsigned char pre_hdr_change[sizeof(struct mail_index_header)];
@@ -24,13 +25,13 @@
 	unsigned char post_hdr_change[sizeof(struct mail_index_header)];
 	unsigned char post_hdr_mask[sizeof(struct mail_index_header)];
 
-	array_t ARRAY_DEFINE(ext_rec_updates, array_t);
-	array_t ARRAY_DEFINE(ext_resizes, struct mail_transaction_ext_intro);
-	array_t ARRAY_DEFINE(ext_resets, uint32_t);
+	ARRAY_DEFINE(ext_rec_updates, ARRAY_TYPE(seq_array));
+	ARRAY_DEFINE(ext_resizes, struct mail_transaction_ext_intro);
+	ARRAY_DEFINE(ext_resets, uint32_t);
 
-	array_t ARRAY_DEFINE(keyword_updates,
-			     struct mail_index_transaction_keyword_update);
-	array_t ARRAY_DEFINE(keyword_resets, struct seq_range);
+	ARRAY_DEFINE(keyword_updates,
+		     struct mail_index_transaction_keyword_update);
+	ARRAY_TYPE(seq_range) keyword_resets;
 
         struct mail_cache_transaction_ctx *cache_trans_ctx;
 
@@ -49,7 +50,7 @@
 void mail_index_transaction_ref(struct mail_index_transaction *t);
 void mail_index_transaction_unref(struct mail_index_transaction **t);
 
-bool mail_index_seq_array_lookup(const array_t *buffer, uint32_t seq,
-				 unsigned int *idx_r);
+bool mail_index_seq_array_lookup(const ARRAY_TYPE(seq_array) *array,
+				 uint32_t seq, unsigned int *idx_r);
 
 #endif

Index: mail-index-transaction-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction-view.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- mail-index-transaction-view.c	12 Jun 2006 12:27:29 -0000	1.17
+++ mail-index-transaction-view.c	28 Jun 2006 13:10:38 -0000	1.18
@@ -145,8 +145,7 @@
 {
 	struct mail_index_view_transaction *tview =
 		(struct mail_index_view_transaction *)view;
-	const array_t *ext_buf;
-	ARRAY_SET_TYPE(ext_buf, void *);
+	const ARRAY_TYPE(seq_array) *ext_buf;
 	const void *data;
 	unsigned int idx;
 

Index: mail-index-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-transaction.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -d -r1.76 -r1.77
--- mail-index-transaction.c	2 May 2006 22:05:09 -0000	1.76
+++ mail-index-transaction.c	28 Jun 2006 13:10:38 -0000	1.77
@@ -43,11 +43,11 @@
 
 static void mail_index_transaction_free(struct mail_index_transaction *t)
 {
-	array_t *recs;
+	ARRAY_TYPE(seq_array) *recs;
 	unsigned i, count;
 
 	if (array_is_created(&t->ext_rec_updates)) {
-		recs = array_get_modifyable(&t->ext_rec_updates, &count);
+		recs = array_get_modifiable(&t->ext_rec_updates, &count);
 
 		for (i = 0; i < count; i++) {
 			if (array_is_created(&recs[i]))
@@ -59,7 +59,7 @@
 	if (array_is_created(&t->keyword_updates)) {
 		struct mail_index_transaction_keyword_update *u;
 
-		u = array_get_modifyable(&t->keyword_updates, &count);
+		u = array_get_modifiable(&t->keyword_updates, &count);
 
 		for (i = 0; i < count; i++) {
 			if (array_is_created(&u[i].add_seq))
@@ -102,10 +102,9 @@
 		mail_index_transaction_free(t);
 }
 
-bool mail_index_seq_array_lookup(const array_t *array, uint32_t seq,
-				 unsigned int *idx_r)
+bool mail_index_seq_array_lookup(const ARRAY_TYPE(seq_array) *array,
+				 uint32_t seq, unsigned int *idx_r)
 {
-        ARRAY_SET_TYPE(array, uint32_t);
 	unsigned int idx, left_idx, right_idx, count;
 	const uint32_t *seq_p;
 
@@ -140,24 +139,22 @@
 	return FALSE;
 }
 
-static bool mail_index_seq_array_add(array_t *array, uint32_t seq,
+static bool mail_index_seq_array_add(ARRAY_TYPE(seq_array) *array, uint32_t seq,
 				     const void *record, size_t record_size,
 				     void *old_record)
 {
-        ARRAY_SET_TYPE(array, void *);
 	void *p;
 	unsigned int idx;
 
 	if (!array_is_created(array)) {
-		array_create(array, default_pool,
-			     sizeof(seq) + record_size,
+		array_create(array, default_pool, sizeof(seq) + record_size,
 			     1024 / (sizeof(seq) + record_size));
 	}
-	i_assert(array->element_size == sizeof(seq) + record_size);
+	i_assert(array->arr.element_size == sizeof(seq) + record_size);
 
 	if (mail_index_seq_array_lookup(array, seq, &idx)) {
 		/* already there, update */
-		p = array_idx_modifyable(array, idx);
+		p = array_idx_modifiable(array, idx);
 		if (old_record != NULL) {
 			/* save the old record before overwriting it */
 			memcpy(old_record, PTR_OFFSET(p, sizeof(seq)),
@@ -176,9 +173,8 @@
 
 static void
 mail_index_buffer_convert_to_uids(struct mail_index_transaction *t,
-				  array_t *array, bool range)
+				  ARRAY_TYPE(seq_array) *array, bool range)
 {
-        ARRAY_SET_TYPE(array, uint32_t);
         struct mail_index_view *view = t->view;
 	const struct mail_index_record *rec;
 	uint32_t *seq;
@@ -190,7 +186,7 @@
 	count = array_count(array);
 	range_count = range ? 1 : 0;
 	for (i = 0; i < count; i++) {
-		seq = array_idx_modifyable(array, i);
+		seq = array_idx_modifiable(array, i);
 
 		for (j = 0; j <= range_count; j++, seq++) {
 			i_assert(*seq > 0);
@@ -215,25 +211,6 @@
 	}
 }
 
-static void arrays_convert_to_uids(struct mail_index_transaction *t,
-				   array_t *array, bool range)
-{
-	ARRAY_SET_TYPE(array, array_t);
-	array_t *updates;
-	unsigned int i, count;
-
-	if (!array_is_created(array))
-		return;
-
-	updates = array_get_modifyable(array, &count);
-	for (i = 0; i < count; i++) {
-		if (array_is_created(&updates[i])) {
-			mail_index_buffer_convert_to_uids(t, &updates[i],
-							  range);
-		}
-	}
-}
-
 static void keyword_updates_convert_to_uids(struct mail_index_transaction *t)
 {
         struct mail_index_transaction_keyword_update *updates;
@@ -242,15 +219,15 @@
 	if (!array_is_created(&t->keyword_updates))
 		return;
 
-	updates = array_get_modifyable(&t->keyword_updates, &count);
+	updates = array_get_modifiable(&t->keyword_updates, &count);
 	for (i = 0; i < count; i++) {
 		if (array_is_created(&updates[i].add_seq)) {
 			mail_index_buffer_convert_to_uids(t,
-				&updates[i].add_seq, TRUE);
+				(void *)&updates[i].add_seq, TRUE);
 		}
 		if (array_is_created(&updates[i].remove_seq)) {
 			mail_index_buffer_convert_to_uids(t,
-				&updates[i].remove_seq, TRUE);
+				(void *)&updates[i].remove_seq, TRUE);
 		}
 	}
 }
@@ -258,15 +235,27 @@
 static int
 mail_index_transaction_convert_to_uids(struct mail_index_transaction *t)
 {
+	ARRAY_TYPE(seq_array) *updates;
+	unsigned int i, count;
+
 	if (mail_index_view_lock(t->view) < 0)
 		return -1;
 
-	arrays_convert_to_uids(t, &t->ext_rec_updates, FALSE);
+	if (array_is_created(&t->ext_rec_updates)) {
+		updates = array_get_modifiable(&t->ext_rec_updates, &count);
+		for (i = 0; i < count; i++) {
+			if (!array_is_created(&updates[i]))
+				continue;
+			mail_index_buffer_convert_to_uids(t, &updates[i],
+							  FALSE);
+		}
+	}
+
         keyword_updates_convert_to_uids(t);
 
-	mail_index_buffer_convert_to_uids(t, &t->expunges, TRUE);
-	mail_index_buffer_convert_to_uids(t, &t->updates, TRUE);
-	mail_index_buffer_convert_to_uids(t, &t->keyword_resets, TRUE);
+	mail_index_buffer_convert_to_uids(t, (void *)&t->expunges, TRUE);
+	mail_index_buffer_convert_to_uids(t, (void *)&t->updates, TRUE);
+	mail_index_buffer_convert_to_uids(t, (void *)&t->keyword_resets, TRUE);
 	return 0;
 }
 
@@ -288,12 +277,12 @@
 {
 	struct mail_index_record *recs, *sorted_recs;
 	struct uid_map *new_uid_map;
-	array_t *ext_rec_arrays;
+	ARRAY_TYPE(seq_array) *ext_rec_arrays;
 	uint32_t *old_to_new_map;
 	unsigned int i, j, count, ext_rec_array_count;
 
 	/* first make a copy of the UIDs and map them to sequences */
-	recs = array_get_modifyable(&t->appends, &count);
+	recs = array_get_modifiable(&t->appends, &count);
 	new_uid_map = i_new(struct uid_map, count);
 	for (i = 0; i < count; i++) {
 		new_uid_map[i].idx = i;
@@ -311,17 +300,16 @@
 	sorted_recs = i_new(struct mail_index_record, count);
 	for (i = 0; i < count; i++)
 		sorted_recs[i] = recs[new_uid_map[i].idx];
-	buffer_write(t->appends.buffer, 0, sorted_recs,
+	buffer_write(t->appends.arr.buffer, 0, sorted_recs,
 		     sizeof(*sorted_recs) * count);
 	i_free(sorted_recs);
 
 	/* fix the order in extensions */
-	ext_rec_arrays = array_get_modifyable(&t->ext_rec_updates,
+	ext_rec_arrays = array_get_modifiable(&t->ext_rec_updates,
 					      &ext_rec_array_count);
 	for (j = 0; j < ext_rec_array_count; j++) {
-		array_t *old_array = &ext_rec_arrays[j];
-		ARRAY_SET_TYPE(old_array, void);
-		array_t new_array;
+		ARRAY_TYPE(seq_array) *old_array = &ext_rec_arrays[j];
+		ARRAY_TYPE(seq_array) new_array;
 		unsigned int ext_count;
 		const uint32_t *ext_rec;
 		uint32_t seq;
@@ -331,7 +319,7 @@
 
 		ext_count = array_count(old_array);
 		array_create(&new_array, default_pool,
-			     old_array->element_size, ext_count);
+			     old_array->arr.element_size, ext_count);
 		for (i = 0; i < ext_count; i++) {
 			ext_rec = array_idx(old_array, i);
 
@@ -339,7 +327,7 @@
 				(t->first_new_seq +
 				 old_to_new_map[*ext_rec - t->first_new_seq]);
 			mail_index_seq_array_add(&new_array, seq, ext_rec+1,
-						 old_array->element_size -
+						 old_array->arr.element_size -
 						 sizeof(*ext_rec), NULL);
 		}
 		array_free(old_array);
@@ -399,7 +387,7 @@
 {
 	i_assert(seq >= t->first_new_seq && seq <= t->last_new_seq);
 
-	return array_idx_modifyable(&t->appends, seq - t->first_new_seq);
+	return array_idx_modifiable(&t->appends, seq - t->first_new_seq);
 }
 
 void mail_index_append(struct mail_index_transaction *t, uint32_t uid,
@@ -446,7 +434,7 @@
 	if (!array_is_created(&t->appends))
 		return;
 
-	recs = array_get_modifyable(&t->appends, &count);
+	recs = array_get_modifiable(&t->appends, &count);
 
 	/* find the first mail with uid = 0 */
 	for (i = 0; i < count; i++) {
@@ -481,7 +469,7 @@
 	unsigned int count;
 	uint32_t idx, move;
 
-	updates = array_get_modifyable(&t->updates, &count);
+	updates = array_get_modifiable(&t->updates, &count);
 
 	i_assert(left_idx <= right_idx && right_idx <= count);
 
@@ -526,7 +514,7 @@
 			i_assert(updates[idx].uid1 <= updates[idx].uid2);
 
 			array_insert(&t->updates, idx, &tmp_update, 1);
-			updates = array_get_modifyable(&t->updates, &count);
+			updates = array_get_modifiable(&t->updates, &count);
 			idx += move;
 		} else if (u.uid1 < updates[idx].uid1) {
 			updates[idx].uid1 = u.uid1;
@@ -544,7 +532,7 @@
 			i_assert(updates[idx].uid1 <= updates[idx].uid2);
 
 			array_insert(&t->updates, idx, &tmp_update, 1);
-			updates = array_get_modifyable(&t->updates, &count);
+			updates = array_get_modifiable(&t->updates, &count);
 		}
 
 		updates[idx].add_flags =
@@ -641,7 +629,7 @@
 		return;
 	}
 
-	last_update = array_get_modifyable(&t->updates, &count);
+	last_update = array_get_modifiable(&t->updates, &count);
 	if (t->last_update_idx < count) {
 		/* fast path - hopefully we're updating the next message,
 		   or a message that is to be appended as last update */
@@ -763,9 +751,9 @@
 	if (array_is_created(&t->ext_rec_updates) &&
 	    ext_id < array_count(&t->ext_rec_updates)) {
 		/* if extension records have been updated, clear them */
-		array_t *array;
+		ARRAY_TYPE(seq_array) *array;
 
-		array = array_idx_modifyable(&t->ext_rec_updates, ext_id);
+		array = array_idx_modifiable(&t->ext_rec_updates, ext_id);
 		if (array_is_created(array))
 			array_clear(array);
 	}
@@ -791,7 +779,7 @@
         const struct mail_index_registered_ext *rext;
 	const struct mail_transaction_ext_intro *intro;
 	uint16_t record_size;
-	array_t *array;
+	ARRAY_TYPE(seq_array) *array;
 	unsigned int count;
 
 	i_assert(seq > 0 &&
@@ -817,9 +805,9 @@
 
 	if (!array_is_created(&t->ext_rec_updates)) {
 		ARRAY_CREATE(&t->ext_rec_updates, default_pool,
-			     array_t, ext_id + 2);
+			     ARRAY_TYPE(seq_array), ext_id + 2);
 	}
-	array = array_idx_modifyable(&t->ext_rec_updates, ext_id);
+	array = array_idx_modifiable(&t->ext_rec_updates, ext_id);
 
 	/* @UNSAFE */
 	if (!mail_index_seq_array_add(array, seq, data, record_size,
@@ -862,9 +850,9 @@
 
 struct mail_keywords *
 mail_index_keywords_create_from_indexes(struct mail_index_transaction *t,
-					const array_t *keyword_indexes)
+					const ARRAY_TYPE(keyword_indexes)
+						*keyword_indexes)
 {
-	ARRAY_SET_TYPE(keyword_indexes, unsigned int);
 	struct mail_keywords *k;
 	unsigned int count;
 
@@ -920,7 +908,7 @@
 	switch (modify_type) {
 	case MODIFY_ADD:
 		for (i = 0; i < keywords->count; i++) {
-			u = array_idx_modifyable(&t->keyword_updates,
+			u = array_idx_modifiable(&t->keyword_updates,
 						 keywords->idx[i]);
 			seq_range_array_add(&u->add_seq, 16, seq);
 			if (seq < t->first_new_seq)
@@ -929,7 +917,7 @@
 		break;
 	case MODIFY_REMOVE:
 		for (i = 0; i < keywords->count; i++) {
-			u = array_idx_modifyable(&t->keyword_updates,
+			u = array_idx_modifiable(&t->keyword_updates,
 						 keywords->idx[i]);
 			seq_range_array_remove(&u->add_seq, seq);
 			if (seq < t->first_new_seq)
@@ -939,7 +927,7 @@
 	case MODIFY_REPLACE:
 		/* Remove sequence from all add/remove arrays */
 		if (array_is_created(&t->keyword_updates)) {
-			u = array_get_modifyable(&t->keyword_updates,
+			u = array_get_modifiable(&t->keyword_updates,
 						 &ku_count);
 			for (i = 0; i < ku_count; i++) {
 				seq_range_array_remove(&u[i].add_seq, seq);
@@ -951,7 +939,7 @@
 		}
 		/* Add the wanted keyword back */
 		for (i = 0; i < keywords->count; i++) {
-			u = array_idx_modifyable(&t->keyword_updates,
+			u = array_idx_modifiable(&t->keyword_updates,
 						 keywords->idx[i]);
 			seq_range_array_add(&u->add_seq, 16, seq);
 		}

Index: mail-index-view-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-private.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mail-index-view-private.h	16 Jun 2006 09:47:13 -0000	1.23
+++ mail-index-view-private.h	28 Jun 2006 13:10:38 -0000	1.24
@@ -3,6 +3,12 @@
 
 #include "mail-index-private.h"
 
+struct mail_index_view_log_sync_pos {
+	uint32_t log_file_seq;
+	uoff_t log_file_offset;
+};
+ARRAY_DEFINE_TYPE(view_log_sync_pos, struct mail_index_view_log_sync_pos);
+
 struct mail_index_view_methods {
 	void (*close)(struct mail_index_view *view);
 	uint32_t (*get_messages_count)(struct mail_index_view *view);
@@ -39,16 +45,16 @@
 	struct mail_index_map *sync_new_map;
 	/* All mappings where we have returned records. They need to be kept
 	   valid until view is synchronized. */
-	array_t ARRAY_DEFINE(map_refs, struct mail_index_map *);
+	ARRAY_DEFINE(map_refs, struct mail_index_map *);
 
 	struct mail_index_header hdr;
 
 	uint32_t log_file_seq;
 	uoff_t log_file_offset;
 	/* Transaction log offsets which we have already synced */
-	array_t ARRAY_DEFINE(syncs_done, struct mail_index_view_log_sync_pos);
+	ARRAY_TYPE(view_log_sync_pos) syncs_done;
 	/* Transaction log offsets which we don't want to return in view sync */
-	array_t ARRAY_DEFINE(syncs_hidden, struct mail_index_view_log_sync_pos);
+	ARRAY_TYPE(view_log_sync_pos) syncs_hidden;
 
 	int transactions;
 	unsigned int lock_id;

Index: mail-index-view-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view-sync.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- mail-index-view-sync.c	16 Jun 2006 09:47:13 -0000	1.53
+++ mail-index-view-sync.c	28 Jun 2006 13:10:38 -0000	1.54
@@ -12,7 +12,7 @@
 	struct mail_index_view *view;
 	enum mail_transaction_type visible_sync_mask;
 	struct mail_index_sync_map_ctx sync_map_ctx;
-	array_t ARRAY_DEFINE(expunges, struct mail_transaction_expunge);
+	ARRAY_TYPE(uid_range) expunges;
 
 	const struct mail_transaction_header *hdr;
 	const void *data;
@@ -23,26 +23,18 @@
 	unsigned int sync_map_update:1;
 };
 
-struct mail_index_view_log_sync_pos {
-	uint32_t log_file_seq;
-	uoff_t log_file_offset;
-};
-
 static void
-mail_transaction_log_sort_expunges(array_t *expunges,
-				   const struct mail_transaction_expunge *src,
-				   size_t src_size)
+mail_transaction_log_sort_expunges(ARRAY_TYPE(uid_range) *expunges,
+				   const struct uid_range *src, size_t src_size)
 {
-	ARRAY_SET_TYPE(expunges, struct mail_transaction_expunge);
-	const struct mail_transaction_expunge *src_end;
-	struct mail_transaction_expunge *dest;
-	struct mail_transaction_expunge new_exp;
+	const struct uid_range *src_end;
+	struct uid_range *dest, new_exp;
 	unsigned int first, i, dest_count;
 
 	i_assert(src_size % sizeof(*src) == 0);
 
 	/* @UNSAFE */
-	dest = array_get_modifyable(expunges, &dest_count);
+	dest = array_get_modifiable(expunges, &dest_count);
 	if (dest_count == 0) {
 		array_append(expunges, src, src_size / sizeof(*src));
 		return;
@@ -77,7 +69,7 @@
 			array_insert(expunges, i, &new_exp, 1);
 			i++; first++;
 
-			dest = array_get_modifyable(expunges, &dest_count);
+			dest = array_get_modifiable(expunges, &dest_count);
 		} else {
 			/* use next record */
 			dest[first] = new_exp;
@@ -87,7 +79,7 @@
 		if (i > first) {
 			array_delete(expunges, first, i - first);
 
-			dest = array_get_modifyable(expunges, &dest_count);
+			dest = array_get_modifiable(expunges, &dest_count);
 			i = first;
 		}
 	}
@@ -119,11 +111,11 @@
 }
 
 static int
-view_sync_get_expunges(struct mail_index_view *view, array_t *expunges_r)
+view_sync_get_expunges(struct mail_index_view *view,
+		       ARRAY_TYPE(uid_range) *expunges_r)
 {
-	ARRAY_SET_TYPE(expunges_r, struct mail_transaction_expunge);
 	const struct mail_transaction_header *hdr;
-	struct mail_transaction_expunge *src, *src_end, *dest;
+	struct uid_range *src, *src_end, *dest;
 	const void *data;
 	unsigned int count;
 	int ret;
@@ -131,8 +123,7 @@
 	if (view_sync_set_log_view_range(view, MAIL_TRANSACTION_EXPUNGE) < 0)
 		return -1;
 
-	ARRAY_CREATE(expunges_r, default_pool,
-		     struct mail_transaction_expunge, 64);
+	ARRAY_CREATE(expunges_r, default_pool, struct uid_range, 64);
 	while ((ret = mail_transaction_log_view_next(view->log_view,
 						     &hdr, &data, NULL)) > 0) {
 		i_assert((hdr->type & MAIL_TRANSACTION_EXPUNGE) != 0);
@@ -145,7 +136,7 @@
 	}
 
 	/* convert to sequences */
-	src = dest = array_get_modifyable(expunges_r, &count);
+	src = dest = array_get_modifiable(expunges_r, &count);
 	src_end = src + count;
 	for (; src != src_end; src++) {
 		ret = mail_index_lookup_uid_range(view, src->uid1,
@@ -204,7 +195,7 @@
 	struct mail_index_view_sync_ctx *ctx;
 	struct mail_index_map *map;
 	enum mail_transaction_type log_get_mask, visible_mask;
-	array_t expunges = { 0, 0 };
+	ARRAY_TYPE(uid_range) expunges = ARRAY_INIT;
 
 	/* We must sync flags as long as view is mmap()ed, as the flags may
 	   have already changed under us. */
@@ -317,9 +308,9 @@
 	return 0;
 }
 
-static bool view_sync_pos_find(array_t *sync_arr, uint32_t seq, uoff_t offset)
+static bool view_sync_pos_find(ARRAY_TYPE(view_log_sync_pos) *sync_arr,
+			       uint32_t seq, uoff_t offset)
 {
-	ARRAY_SET_TYPE(sync_arr, struct mail_index_view_log_sync_pos);
 	const struct mail_index_view_log_sync_pos *syncs;
 	unsigned int i, count;
 
@@ -524,7 +515,7 @@
 mail_index_view_sync_get_expunges(struct mail_index_view_sync_ctx *ctx,
 				  unsigned int *count_r)
 {
-	const struct mail_transaction_expunge *data;
+	const struct uid_range *data;
 
 	data = array_get(&ctx->expunges, count_r);
 	return (const uint32_t *)data;
@@ -532,9 +523,8 @@
 
 static void
 mail_index_view_sync_clean_log_syncs(struct mail_index_view_sync_ctx *ctx,
-				     array_t *sync_arr)
+				     ARRAY_TYPE(view_log_sync_pos) *sync_arr)
 {
-	ARRAY_SET_TYPE(sync_arr, struct mail_index_view_log_sync_pos);
 	struct mail_index_view *view = ctx->view;
 	const struct mail_index_view_log_sync_pos *syncs;
 	unsigned int i, count;
@@ -600,10 +590,9 @@
 	i_free(ctx);
 }
 
-static void log_sync_pos_add(array_t *sync_arr, uint32_t log_file_seq,
-			     uoff_t log_file_offset)
+static void log_sync_pos_add(ARRAY_TYPE(view_log_sync_pos) *sync_arr,
+			     uint32_t log_file_seq, uoff_t log_file_offset)
 {
-	ARRAY_SET_TYPE(sync_arr, struct mail_index_view_log_sync_pos);
 	struct mail_index_view_log_sync_pos *pos;
 
 	if (!array_is_created(sync_arr)) {

Index: mail-index-view.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- mail-index-view.c	16 Jun 2006 09:47:13 -0000	1.45
+++ mail-index-view.c	28 Jun 2006 13:10:38 -0000	1.46
@@ -162,7 +162,7 @@
 	if (!array_is_created(&view->map_refs))
 		return;
 
-	maps = array_get_modifyable(&view->map_refs, &count);
+	maps = array_get_modifiable(&view->map_refs, &count);
 	for (i = 0; i < count; i++)
 		mail_index_unmap(view->index, &maps[i]);
 
@@ -482,9 +482,8 @@
 }
 
 int mail_index_lookup_keywords(struct mail_index_view *view, uint32_t seq,
-			       array_t *keyword_idx)
+			       ARRAY_TYPE(keyword_indexes) *keyword_idx)
 {
-	ARRAY_SET_TYPE(keyword_idx, unsigned int);
 	struct mail_index_map *map;
 	const void *data;
 	const unsigned char *keyword_data;

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.235
retrieving revision 1.236
diff -u -d -r1.235 -r1.236
--- mail-index.c	17 Jun 2006 13:42:37 -0000	1.235
+++ mail-index.c	28 Jun 2006 13:10:38 -0000	1.236
@@ -112,7 +112,7 @@
 {
 	struct mail_index_registered_ext *rext;
 
-	rext = array_idx_modifyable(&index->extensions, ext_id);
+	rext = array_idx_modifiable(&index->extensions, ext_id);
 	i_assert(rext->expunge_handler == NULL);
 
 	rext->expunge_handler = cb;
@@ -123,7 +123,7 @@
 {
 	struct mail_index_registered_ext *rext;
 
-	rext = array_idx_modifyable(&index->extensions, ext_id);
+	rext = array_idx_modifiable(&index->extensions, ext_id);
 	i_assert(rext->expunge_handler != NULL);
 
 	rext->expunge_handler = NULL;
@@ -135,7 +135,7 @@
 {
 	struct mail_index_registered_ext *rext;
 
-	rext = array_idx_modifyable(&index->extensions, ext_id);
+	rext = array_idx_modifiable(&index->extensions, ext_id);
 	i_assert(rext->sync_handler.callback == NULL);
 
 	rext->sync_handler.callback = cb;
@@ -147,7 +147,7 @@
 {
 	struct mail_index_registered_ext *rext;
 
-	rext = array_idx_modifyable(&index->extensions, ext_id);
+	rext = array_idx_modifiable(&index->extensions, ext_id);
 	i_assert(rext->sync_handler.callback != NULL);
 
 	rext->sync_handler.callback = NULL;
@@ -182,7 +182,7 @@
 	size_t size;
 
 	if (map->extension_pool == NULL) {
-		size = (sizeof(array_t) + BUFFER_APPROX_SIZE) * 2 +
+		size = (sizeof(map->extensions) + BUFFER_APPROX_SIZE) * 2 +
 			initial_count * (EXTENSION_NAME_APPROX_LEN +
 					 sizeof(struct mail_index_ext) +
 					 sizeof(uint32_t));
@@ -484,7 +484,7 @@
 	return 0;
 }
 
-const array_t *mail_index_get_keywords(struct mail_index *index)
+const ARRAY_TYPE(keywords) *mail_index_get_keywords(struct mail_index *index)
 {
 	/* Make sure all the keywords are in index->keywords. It's quick to do
 	   if nothing has changed. */
@@ -1163,7 +1163,7 @@
 		}
 	}
 
-	mem_map->records = buffer_get_modifyable_data(mem_map->buffer, NULL);
+	mem_map->records = buffer_get_modifiable_data(mem_map->buffer, NULL);
 	mem_map->records_count = map->records_count;
 
 	mem_map->hdr_copy_buf =
@@ -1177,7 +1177,7 @@
 				       map->hdr.base_header_size),
 		      map->hdr.header_size - map->hdr.base_header_size);
 
-	hdr = buffer_get_modifyable_data(mem_map->hdr_copy_buf, NULL);
+	hdr = buffer_get_modifiable_data(mem_map->hdr_copy_buf, NULL);
 	if (hdr->base_header_size < sizeof(*hdr))
 		hdr->base_header_size = sizeof(*hdr);
 	hdr->record_size = new_record_size;
@@ -1202,7 +1202,7 @@
 		array_append_array(&mem_map->ext_id_map, &map->ext_id_map);
 
 		/* fix the name pointers to use our own pool */
-		extensions = array_get_modifyable(&mem_map->extensions, &count);
+		extensions = array_get_modifiable(&mem_map->extensions, &count);
 		for (i = 0; i < count; i++) {
 			extensions[i].name = p_strdup(mem_map->extension_pool,
 						      extensions[i].name);

Index: mail-index.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.158
retrieving revision 1.159
diff -u -d -r1.158 -r1.159
--- mail-index.h	18 Jan 2006 23:04:15 -0000	1.158
+++ mail-index.h	28 Jun 2006 13:10:38 -0000	1.159
@@ -142,6 +142,8 @@
 	enum mail_index_sync_type type;
 };
 
+ARRAY_DEFINE_TYPE(keyword_indexes, unsigned int);
+
 struct mail_index;
 struct mail_index_map;
 struct mail_index_view;
@@ -282,7 +284,7 @@
 			   const struct mail_index_record **rec_r);
 /* Note that returned keyword indexes aren't sorted. */
 int mail_index_lookup_keywords(struct mail_index_view *view, uint32_t seq,
-			       array_t *keyword_idx);
+			       ARRAY_TYPE(keyword_indexes) *keyword_idx);
 /* Returns the UID for given message. May be slightly faster than
    mail_index_lookup()->uid. */
 int mail_index_lookup_uid(struct mail_index_view *view, uint32_t seq,
@@ -325,7 +327,7 @@
 /* Return a pointer to array of NULL-terminated list of keywords. Note that
    the array contents (and thus pointers inside it) may change after calling
    mail_index_keywords_create() or mail_index_sync_begin(). */
-const array_t *mail_index_get_keywords(struct mail_index *index);
+const ARRAY_TYPE(keywords) *mail_index_get_keywords(struct mail_index *index);
 
 /* Create a keyword list structure. It's freed automatically at the end of
    the transaction. */
@@ -334,7 +336,8 @@
 			   const char *const keywords[]);
 struct mail_keywords *
 mail_index_keywords_create_from_indexes(struct mail_index_transaction *t,
-					const array_t *keyword_indexes);
+					const ARRAY_TYPE(keyword_indexes)
+						*keyword_indexes);
 /* Free the keywords. */
 void mail_index_keywords_free(struct mail_keywords **keywords);
 /* Update keywords for given message. */
@@ -363,7 +366,7 @@
 /* Apply changes in MAIL_INDEX_SYNC_TYPE_KEYWORD_* typed sync records to given
    keywords array. Returns TRUE If something was changed. */
 bool mail_index_sync_keywords_apply(const struct mail_index_sync_rec *sync_rec,
-				    array_t *keywords);
+				    ARRAY_TYPE(keyword_indexes) *keywords);
 
 /* register index extension. name is a unique identifier for the extension.
    returns unique identifier for the name. */

Index: mail-transaction-log-append.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log-append.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mail-transaction-log-append.c	16 Jun 2006 09:47:13 -0000	1.18
+++ mail-transaction-log-append.c	28 Jun 2006 13:10:38 -0000	1.19
@@ -152,7 +152,7 @@
 		intro = NULL;
 		count = 0;
 	} else {
-		intro = array_get_modifyable(&t->ext_resizes, &count);
+		intro = array_get_modifiable(&t->ext_resizes, &count);
 	}
 
 	buf = buffer_create_dynamic(pool_datastack_create(), 128);
@@ -203,7 +203,7 @@
 	unsigned int update_count, resize_count, reset_count, ext_count;
 	uint32_t ext_id;
 	const uint32_t *reset;
-	const array_t *update;
+	const ARRAY_TYPE(seq_array) *update;
 	buffer_t *buf;
 
 	if (!array_is_created(&t->ext_rec_updates)) {
@@ -259,7 +259,7 @@
 static int log_append_ext_rec_updates(struct mail_transaction_log_file *file,
 				      struct mail_index_transaction *t)
 {
-	array_t *updates;
+	ARRAY_TYPE(seq_array) *updates;
 	const uint32_t *reset;
 	unsigned int ext_id, count, reset_count;
 	uint32_t reset_id;
@@ -268,14 +268,14 @@
 		updates = NULL;
 		count = 0;
 	} else {
-		updates = array_get_modifyable(&t->ext_rec_updates, &count);
+		updates = array_get_modifiable(&t->ext_rec_updates, &count);
 	}
 
 	if (!array_is_created(&t->ext_resets)) {
 		reset = NULL;
 		reset_count = 0;
 	} else {
-		reset = array_get_modifyable(&t->ext_resets, &reset_count);
+		reset = array_get_modifiable(&t->ext_resets, &reset_count);
 	}
 
 	for (ext_id = 0; ext_id < count; ext_id++) {
@@ -287,7 +287,7 @@
 		if (log_append_ext_intro(file, t, ext_id, reset_id) < 0)
 			return -1;
 
-		if (log_append_buffer(file, updates[ext_id].buffer, NULL,
+		if (log_append_buffer(file, updates[ext_id].arr.buffer, NULL,
 				      MAIL_TRANSACTION_EXT_REC_UPDATE,
 				      t->external) < 0)
 			return -1;
@@ -332,22 +332,22 @@
 
 	hdr_buf = buffer_create_dynamic(pool_datastack_create(), 64);
 
-	keywords = array_get_modifyable(&t->view->index->keywords,
+	keywords = array_get_modifiable(&t->view->index->keywords,
 					&keywords_count);
-	updates = array_get_modifyable(&t->keyword_updates, &count);
+	updates = array_get_modifiable(&t->keyword_updates, &count);
 	i_assert(count <= keywords_count);
 
 	for (i = 0; i < count; i++) {
 		if (array_is_created(&updates[i].add_seq)) {
 			if (log_append_keyword_update(file, t, hdr_buf,
 					MODIFY_ADD, keywords[i],
-					updates[i].add_seq.buffer) < 0)
+					updates[i].add_seq.arr.buffer) < 0)
 				return -1;
 		}
 		if (array_is_created(&updates[i].remove_seq)) {
 			if (log_append_keyword_update(file, t, hdr_buf,
 					MODIFY_REMOVE, keywords[i],
-					updates[i].remove_seq.buffer) < 0)
+					updates[i].remove_seq.arr.buffer) < 0)
 				return -1;
 		}
 	}
@@ -454,7 +454,7 @@
 			mail_index_view_add_hidden_transaction(view,
 				file->hdr.file_seq, file->sync_offset);
 		}
-		ret = log_append_buffer(file, t->appends.buffer, NULL,
+		ret = log_append_buffer(file, t->appends.arr.buffer, NULL,
 					MAIL_TRANSACTION_APPEND, t->external);
 	}
 	if (array_is_created(&t->updates) && ret == 0) {
@@ -462,7 +462,7 @@
 			mail_index_view_add_hidden_transaction(view,
 				file->hdr.file_seq, file->sync_offset);
 		}
-		ret = log_append_buffer(file, t->updates.buffer, NULL,
+		ret = log_append_buffer(file, t->updates.arr.buffer, NULL,
 					MAIL_TRANSACTION_FLAG_UPDATE,
 					t->external);
 	}
@@ -476,8 +476,8 @@
 			mail_index_view_add_hidden_transaction(view,
 				file->hdr.file_seq, file->sync_offset);
 		}
-		ret = log_append_buffer(file, t->keyword_resets.buffer, NULL,
-					MAIL_TRANSACTION_KEYWORD_RESET,
+		ret = log_append_buffer(file, t->keyword_resets.arr.buffer,
+					NULL, MAIL_TRANSACTION_KEYWORD_RESET,
 					t->external);
 	}
 	if (array_is_created(&t->keyword_updates) && ret == 0)
@@ -485,7 +485,7 @@
 
 	if (array_is_created(&t->expunges) && ret == 0) {
 		/* Expunges cannot be hidden */
-		ret = log_append_buffer(file, t->expunges.buffer, NULL,
+		ret = log_append_buffer(file, t->expunges.arr.buffer, NULL,
 					MAIL_TRANSACTION_EXPUNGE, t->external);
 	}
 



More information about the dovecot-cvs mailing list