From: Sebastian B. <sb...@us...> - 2014-01-19 18:40:26
|
Update of /cvsroot/simplemail/simplemail In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv23517 Modified Files: index_external.c Log Message: Added another debug function to count the number of leaves. Index: index_external.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/index_external.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- index_external.c 19 Jan 2014 18:40:05 -0000 1.23 +++ index_external.c 19 Jan 2014 18:40:23 -0000 1.24 @@ -394,6 +394,40 @@ bnode_free(idx, tmp); } + +/** + * Verify whether the index is consitent, i.e., whether all strings are in increasing order. + * + * @param + * @param block + * @param level + */ +static int count_index(struct index_external *idx, int block, int level) +{ + int i, count = 0; + bnode *tmp = bnode_create(idx); + + if (!bnode_read_block(idx, tmp, block)) + return; + + if (!tmp->leaf) + count += count_index(idx, tmp->lchild, level + 1); + + for (i=0; i<tmp->num_elements; i++) + { + struct bnode_element *e; + int rc; + + e = bnode_get_ith_element_of_node(idx, tmp, i); + if (!tmp->leaf) + count += count_index(idx, e->gchild, level + 1); + count++; + } + + bnode_free(idx, tmp); + return count; +} + /** * Inserts the given string into the bnode tree. * |