[dovecot-cvs] dovecot/src/plugins/fts-squat squat-trie.c, 1.14, 1.15

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


Update of /var/lib/cvs/dovecot/src/plugins/fts-squat
In directory talvi:/tmp/cvs-serv17750/plugins/fts-squat

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



Index: squat-trie.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/plugins/fts-squat/squat-trie.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- squat-trie.c	24 Jan 2007 14:41:28 -0000	1.14
+++ squat-trie.c	15 Mar 2007 17:02:19 -0000	1.15
@@ -1030,7 +1030,7 @@
 	struct trie_node *node = *parent;
 	struct trie_node **children;
 	uint32_t char_idx;
-	bool modified = FALSE;
+	bool match, modified = FALSE;
 	int ret;
 
 	if (*data < MAX_8BIT_CHAR_COUNT) {
@@ -1045,14 +1045,13 @@
 			char_idx = *data;
 		} else {
 			uint8_t *chars = NODE_CHARS8(node);
-			uint8_t *pos;
 
 			count = node->chars_8bit_count;
-			pos = bsearch_insert_pos(data, chars, count,
-						 sizeof(chars[0]),
-						 chr_8bit_cmp);
-			char_idx = pos - chars;
-			if (char_idx == count || *pos != *data) {
+			match = bsearch_insert_pos(data, chars, count,
+						   sizeof(chars[0]),
+						   chr_8bit_cmp,
+						   &char_idx);
+			if (!match) {
 				node = node_realloc(node, char_idx,
 						    *data, level);
 				*parent = node;
@@ -1071,7 +1070,7 @@
 			modified = TRUE;
 		} else {
 			unsigned int idx_size;
-			uint16_t *chars, *pos;
+			uint16_t *chars;
 
 			idx_size = level < BLOCK_SIZE ?
 				sizeof(struct trie_node *) : sizeof(uint32_t);
@@ -1080,11 +1079,11 @@
 			chars = PTR_OFFSET(node, offset);
 
 			count = node->chars_16bit_count;
-			pos = bsearch_insert_pos(data, chars, count,
-						 sizeof(chars[0]),
-						 chr_16bit_cmp);
-			char_idx = pos - chars;
-			if (char_idx == count || *pos != *data) {
+			match = bsearch_insert_pos(data, chars, count,
+						   sizeof(chars[0]),
+						   chr_16bit_cmp,
+						   &char_idx);
+			if (!match) {
 				node = node_realloc(node, char_idx,
 						    *data, level);
 				*parent = node;



More information about the dovecot-cvs mailing list