X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/70322ae3751bc07ac749dffad79a5f3420e67b55..cc7db507cc53258e23c148c690c9e450214f93ac:/index.c diff --git a/index.c b/index.c index 53f1000..19cde65 100644 --- a/index.c +++ b/index.c @@ -2,13 +2,10 @@ * index.c: Implementation of index.h. */ -#include -#include -#include - +#include "agedu.h" #include "trie.h" #include "index.h" -#include "malloc.h" +#include "alloc.h" #define alignof(typ) ( offsetof(struct { char c; typ t; }, t) ) @@ -139,7 +136,7 @@ static void avl_fix(indexbuild *ib, struct avlnode *n) MAXDEPTH(NODE(ib->t, n->children[1]))); n->totalsize = - (ELEMENT(ib->t, n->element)->blocks + + (ELEMENT(ib->t, n->element)->size + (n->children[0] ? NODE(ib->t, n->children[0])->totalsize : 0) + (n->children[1] ? NODE(ib->t, n->children[1])->totalsize : 0)); } @@ -304,7 +301,7 @@ unsigned long long index_query(const void *t, int n, unsigned long long at) } else { if (left) ret += left->totalsize; - ret += tf->blocks; + ret += tf->size; node = right; } } @@ -334,12 +331,12 @@ unsigned long long index_order_stat(const void *t, double f) if (left && size < left->totalsize) { node = left; } else if (!right || - size < (left ? left->totalsize : 0) + tf->blocks) { + size < (left ? left->totalsize : 0) + tf->size) { return tf->atime; } else { if (left) size -= left->totalsize; - size -= tf->blocks; + size -= tf->size; node = right; } }