[dovecot-cvs] dovecot/src/lib-storage/index index-sort.c, 1.17, 1.18

tss at dovecot.org tss at dovecot.org
Thu Mar 15 19:02:16 EET 2007


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

Modified Files:
	index-sort.c 
Log Message:
bsearch_insert_pos() API changed. Patch by Max Kellermann



Index: index-sort.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-sort.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- index-sort.c	20 Dec 2006 15:13:34 -0000	1.17
+++ index-sort.c	15 Mar 2007 17:02:13 -0000	1.18
@@ -554,8 +554,8 @@
 			       uint32_t last_seq)
 {
 	struct mail_sort_node *nodes, node;
-	const struct mail_sort_node *cnodes, *pos;
-	unsigned int count;
+	const struct mail_sort_node *cnodes;
+	unsigned int count, idx;
 
 	/* we wish to avoid reading the actual headers as much as possible.
 	   first sort the nodes which already have sort_ids, then start
@@ -578,9 +578,10 @@
 				     program->sort_program[0], node.seq);
 
 		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);
+		bsearch_insert_pos(&node, cnodes, count, sizeof(*cnodes),
+				   sort_node_cmp_no_sort_id,
+				   &idx);
+		array_insert(&program->nodes, idx, &node, 1);
 	}
 
 	index_sort_add_ids(program, static_node_cmp_context.mail);
@@ -634,17 +635,18 @@
 static void index_sort_add_node(struct mail_search_sort_program *program,
 				const struct mail_sort_node *node)
 {
-	const struct mail_sort_node *nodes, *pos;
-	unsigned int count;
+	const struct mail_sort_node *nodes;
+	unsigned int count, idx;
 
 	memset(&static_node_cmp_context, 0, sizeof(static_node_cmp_context));
 	static_node_cmp_context.program = program;
 	static_node_cmp_context.mail = program->temp_mail;
 
 	nodes = array_get(&program->nodes, &count);
-	pos = bsearch_insert_pos(node, nodes, count,
-				 sizeof(*node), sort_node_cmp);
-	array_insert(&program->nodes, pos - nodes, node, 1);
+	bsearch_insert_pos(node, nodes, count,
+			   sizeof(*node), sort_node_cmp,
+			   &idx);
+	array_insert(&program->nodes, idx, node, 1);
 
 	program->last_sorted_seq = node->seq;
 	program->prev_seq = node->seq;



More information about the dovecot-cvs mailing list