X-Git-Url: https://git.distorted.org.uk/~mdw/sgt/agedu/blobdiff_plain/995db5990865ab0772e0f0902ba39c1fb9336fa3..645dbd491c48a1558fe16b99c3e4410459dd1852:/trie.c diff --git a/trie.c b/trie.c index eb9fb81..345756f 100644 --- a/trie.c +++ b/trie.c @@ -2,15 +2,6 @@ * trie.c: implementation of trie.h. */ -#include -#include -#include -#include -#include - -#include -#include - #include "agedu.h" #include "alloc.h" #include "trie.h" @@ -637,6 +628,19 @@ triewalk *triewalk_new(const void *vt) return tw; } + +void triewalk_rebase(triewalk *tw, const void *t) +{ + ptrdiff_t diff = ((const unsigned char *)t - (const unsigned char *)(tw->t)); + int i; + + tw->t = t; + + for (i = 0; i < tw->nswitches; i++) + tw->switches[i].sw = (const struct trie_switch *) + ((const unsigned char *)(tw->switches[i].sw) + diff); +} + const struct trie_file *triewalk_next(triewalk *tw, char *buf) { off_t off;