From: Sebastian B. <sb...@us...> - 2014-01-19 18:50:10
|
Update of /cvsroot/simplemail/simplemail In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv24821 Modified Files: index_external.c Log Message: Added count_index_leaves() function. Index: index_external.c =================================================================== RCS file: /cvsroot/simplemail/simplemail/index_external.c,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- index_external.c 19 Jan 2014 18:49:36 -0000 1.41 +++ index_external.c 19 Jan 2014 18:50:08 -0000 1.42 @@ -518,6 +518,40 @@ } /** + * Count the number of strings, to which all the leaves refer. + * + * @param idx + * @param block + * @param level + */ +static int count_index_leaves(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_leaves(idx, e->gchild, level + 1); + else + count++; + } + + bnode_free(idx, tmp); + return count; +} + +/** * Inserts the given string into the bnode tree. * * @param idx |