From 645dbd491c48a1558fe16b99c3e4410459dd1852 Mon Sep 17 00:00:00 2001 From: simon Date: Fri, 7 Nov 2008 20:06:16 +0000 Subject: [PATCH] Oops: when we re-mmap the file, don't forget to rebase the two pointers into it we're actually holding in main() as well as the ones tucked away in subsystems' state. git-svn-id: svn://svn.tartarus.org/sgt/agedu@8289 cda61777-01e9-0310-a592-d414129be87e --- agedu.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/agedu.c b/agedu.c index f823121..5b836e7 100644 --- a/agedu.c +++ b/agedu.c @@ -1088,6 +1088,9 @@ int main(int argc, char **argv) int i; if (totalsize - indexbuild_realsize(ib) < delta) { + const void *oldfile = mappedfile; + ptrdiff_t diff; + /* * Unmap the file, grow it, and remap it. */ @@ -1113,6 +1116,14 @@ int main(int argc, char **argv) indexbuild_rebase(ib, mappedfile); triewalk_rebase(tw, mappedfile); + diff = (const unsigned char *)mappedfile - + (const unsigned char *)oldfile; + if (prevtf) + prevtf = (const struct trie_file *) + (((const unsigned char *)prevtf) + diff); + if (tf) + tf = (const struct trie_file *) + (((const unsigned char *)tf) + diff); } /* -- 2.11.0