[dovecot-cvs] dovecot/src/lib-storage/index index-mail-headers.c, 1.62, 1.63 index-mail.c, 1.100, 1.101 index-mail.h, 1.40, 1.41 index-sort.c, 1.12, 1.13 index-storage.h, 1.102, 1.103 index-sync.c, 1.56, 1.57

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


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

Modified Files:
	index-mail-headers.c index-mail.c index-mail.h index-sort.c 
	index-storage.h index-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: index-mail-headers.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail-headers.c,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -d -r1.62 -r1.63
--- index-mail-headers.c	17 Jun 2006 20:15:10 -0000	1.62
+++ index-mail-headers.c	28 Jun 2006 13:10:49 -0000	1.63
@@ -46,7 +46,7 @@
 
 	t_push();
 
-	lines = array_get_modifyable(&mail->header_lines, &count);
+	lines = array_get_modifiable(&mail->header_lines, &count);
 
 	/* sort it first so fields are grouped together and ordered by
 	   line number */
@@ -299,7 +299,7 @@
 						  data->seq, field_idx);
 	}
 
-	match = array_get_modifyable(&mail->header_match, &count);
+	match = array_get_modifiable(&mail->header_match, &count);
 	if (field_idx < count && match[field_idx] == mail->header_match_value) {
 		/* first header */
 		match[field_idx]++;
@@ -464,7 +464,7 @@
 static const char *const *
 index_mail_get_parsed_header(struct index_mail *mail, unsigned int field_idx)
 {
-	array_t ARRAY_DEFINE(header_values, const char *);
+	ARRAY_DEFINE(header_values, const char *);
         const struct index_mail_line *lines;
 	const unsigned char *header, *value_start, *value_end;
 	const unsigned int *line_idx;
@@ -510,7 +510,7 @@
 	string_t *dest;
 	size_t i, len;
 	int ret;
-	array_t ARRAY_DEFINE(header_values, const char *);
+	ARRAY_DEFINE(header_values, const char *);
 
 	i_assert(field != NULL);
 
@@ -544,7 +544,7 @@
 		return ret == 0 ? NULL :
 			index_mail_get_parsed_header(mail, field_idx);
 	}
-	data = buffer_get_modifyable_data(dest, &len);
+	data = buffer_get_modifiable_data(dest, &len);
 
 	if (len == 0) {
 		/* cached as non-existing. */

Index: index-mail.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.c,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- index-mail.c	8 Jun 2006 12:49:37 -0000	1.100
+++ index-mail.c	28 Jun 2006 13:10:49 -0000	1.101
@@ -146,7 +146,7 @@
 	static const char *const no_keywords[] = { NULL };
 	struct index_mail *mail = (struct index_mail *) _mail;
 	struct index_mail_data *data = &mail->data;
-	array_t ARRAY_DEFINE(keyword_indexes_arr, unsigned int);
+	ARRAY_TYPE(keyword_indexes) keyword_indexes_arr;
 	const char *const *names;
 	const unsigned int *keyword_indexes;
 	unsigned int i, count, names_count;

Index: index-mail.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-mail.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- index-mail.h	16 May 2006 09:10:31 -0000	1.40
+++ index-mail.h	28 Jun 2006 13:10:49 -0000	1.41
@@ -87,7 +87,7 @@
 	struct message_size hdr_size, body_size;
 	struct message_parser_ctx *parser_ctx;
 	int parsing_count;
-	array_t ARRAY_DEFINE(keywords, const char *);
+	ARRAY_TYPE(keywords) keywords;
 
 	const struct mail_cache_field *all_cache_fields;
 	unsigned int all_cache_fields_count;
@@ -119,9 +119,9 @@
 	/* per-mail variables, here for performance reasons: */
 	uint32_t header_seq;
 	string_t *header_data;
-	array_t ARRAY_DEFINE(header_lines, struct index_mail_line);
-	array_t ARRAY_DEFINE(header_match, uint8_t);
-	array_t ARRAY_DEFINE(header_match_lines, unsigned int);
+	ARRAY_DEFINE(header_lines, struct index_mail_line);
+	ARRAY_DEFINE(header_match, uint8_t);
+	ARRAY_DEFINE(header_match_lines, unsigned int);
 	uint8_t header_match_value;
 };
 

Index: index-sort.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-sort.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- index-sort.c	8 Jun 2006 12:49:37 -0000	1.12
+++ index-sort.c	28 Jun 2006 13:10:49 -0000	1.13
@@ -44,6 +44,7 @@
 	uint32_t seq;
 	uint32_t sort_id;
 };
+ARRAY_DEFINE_TYPE(mail_sort_node, struct mail_sort_node);
 
 struct mail_search_sort_program {
 	struct mailbox_transaction_context *t;
@@ -51,11 +52,11 @@
 	const char *primary_sort_header;
 	struct mail *temp_mail;
 
-	array_t ARRAY_DEFINE(nodes, struct mail_sort_node);
+	ARRAY_TYPE(mail_sort_node) nodes;
 	const struct mail_sort_node *nodes_ptr;
 	unsigned int nodes_count, iter_idx;
 
-	array_t ARRAY_DEFINE(all_nodes, struct mail_sort_node);
+	ARRAY_TYPE(mail_sort_node) all_nodes;
 
 	uint32_t ext_id;
 	uint32_t prev_seq, last_sorted_seq;
@@ -333,7 +334,7 @@
 	int ret = 1;
 
 	t_push();
-	nodes = array_get_modifyable(&program->all_nodes, &count);
+	nodes = array_get_modifiable(&program->all_nodes, &count);
 	if (nodes[idx2].sort_id != 0) {
 		i_assert(idx1 != idx2);
 		last_id = nodes[idx2].sort_id;
@@ -395,7 +396,7 @@
 	unsigned int i, count;
 	uint32_t sort_id, prev_sort_id, skip;
 
-	nodes = array_get_modifyable(&program->all_nodes, &count);
+	nodes = array_get_modifiable(&program->all_nodes, &count);
 	prev_sort_id = (uint32_t)-1;
 	sort_id = nodes[idx].sort_id;
 	i_assert(sort_id == nodes[idx + 1].sort_id);
@@ -522,7 +523,7 @@
 	static_node_cmp_context.program = program;
 	static_node_cmp_context.mail = mail;
 
-	qsort(array_idx_modifyable(&program->all_nodes, 0), last_seq,
+	qsort(array_idx_modifiable(&program->all_nodes, 0), last_seq,
 	      sizeof(struct mail_sort_node), sort_node_cmp);
 }
 
@@ -565,7 +566,7 @@
 	static_node_cmp_context.mail = program->temp_mail;
 
 	/* @UNSAFE */
-	nodes = array_get_modifyable(&program->all_nodes, &count);
+	nodes = array_get_modifiable(&program->all_nodes, &count);
 	if (program->last_sorted_seq != count) {
 		qsort(nodes, count, sizeof(struct mail_sort_node),
 		      sort_node_cmp);
@@ -576,7 +577,7 @@
 		index_sort_cache_seq(&static_node_cmp_context,
 				     program->sort_program[0], node.seq);
 
-		cnodes = array_get_modifyable(&program->nodes, &count);
+		cnodes = array_get_modifiable(&program->nodes, &count);
 		pos = bsearch_insert_pos(&node, cnodes, count, sizeof(*cnodes),
 					 sort_node_cmp_no_sort_id);
 		array_insert(&program->nodes, pos - cnodes, &node, 1);

Index: index-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- index-storage.h	8 Jun 2006 12:49:37 -0000	1.102
+++ index-storage.h	28 Jun 2006 13:10:49 -0000	1.103
@@ -62,7 +62,7 @@
 	uint32_t commit_log_file_seq;
 	uoff_t commit_log_file_offset;
 
-	const array_t *ARRAY_DEFINE_PTR(keyword_names, const char *);
+	const ARRAY_TYPE(keywords) *keyword_names;
 	struct mail_cache_field *cache_fields;
 	unsigned int mail_cache_min_mail_count;
 
@@ -183,6 +183,7 @@
 int index_transaction_commit(struct mailbox_transaction_context *t);
 void index_transaction_rollback(struct mailbox_transaction_context *t);
 
-bool index_keyword_array_cmp(const array_t *k1, const array_t *k2);
+bool index_keyword_array_cmp(const ARRAY_TYPE(keyword_indexes) *k1,
+			     const ARRAY_TYPE(keyword_indexes) *k2);
 
 #endif

Index: index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-sync.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -d -r1.56 -r1.57
--- index-sync.c	26 Feb 2006 11:24:38 -0000	1.56
+++ index-sync.c	28 Jun 2006 13:10:49 -0000	1.57
@@ -30,7 +30,7 @@
 		dest_idx = ibox->recent_flags_start_seq - seq;
 		buffer_copy(ibox->recent_flags, dest_idx,
 			    ibox->recent_flags, 0, (size_t)-1);
-		memset(buffer_get_modifyable_data(ibox->recent_flags, NULL),
+		memset(buffer_get_modifiable_data(ibox->recent_flags, NULL),
 		       0, dest_idx);
 		ibox->recent_flags_start_seq = seq;
 	}
@@ -271,10 +271,9 @@
 	return ret;
 }
 
-bool index_keyword_array_cmp(const array_t *k1, const array_t *k2)
+bool index_keyword_array_cmp(const ARRAY_TYPE(keyword_indexes) *k1,
+			     const ARRAY_TYPE(keyword_indexes) *k2)
 {
-	ARRAY_SET_TYPE(k1, unsigned int);
-	ARRAY_SET_TYPE(k2, unsigned int);
 	const unsigned int *idx1, *idx2;
 	unsigned int i, j, count1, count2;
 



More information about the dovecot-cvs mailing list