X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/522edd92f2bbef89ccd1dd0a3e874516fb47e2ef..b02bd008c6a46bcfed857c085e4c157146bc62f1:/index.c diff --git a/index.c b/index.c index db3d2b3..28119c8 100644 --- a/index.c +++ b/index.c @@ -52,7 +52,7 @@ static int index_maxdepth(int nodecount) off_t index_initial_size(off_t currentsize, int nodecount) { currentsize += PADDING(currentsize, alignof(off_t)); - currentsize += nodecount + sizeof(off_t); + currentsize += nodecount * sizeof(off_t); currentsize += PADDING(currentsize, alignof(struct avlnode)); return currentsize; @@ -269,7 +269,9 @@ void indexbuild_rebase(indexbuild *ib, void *t) ib->t = t; ib->nodes = (struct avlnode *)((unsigned char *)ib->nodes + diff); ib->roots = (off_t *)((unsigned char *)ib->roots + diff); - ib->currroot = (struct avlnode *)((unsigned char *)ib->currroot + diff); + if (ib->currroot) + ib->currroot = (struct avlnode *) + ((unsigned char *)ib->currroot + diff); ib->firstmutable = (struct avlnode *)((unsigned char *)ib->firstmutable + diff); }