3 #include "sherlock/sherlock.h"
4 #include "lib/fastbuf.h"
5 #include "images/images.h"
6 #include "sherlock/index.h"
11 struct image_tree image_tree;
16 DBG("Initializing image search structures");
17 struct fastbuf *fb = bopen("index/image-tree", O_RDONLY, 1 << 16); /* FIXME: filename hack */
18 image_tree.count = bgetl(fb);
19 image_tree.depth = bgetl(fb);
20 ASSERT(image_tree.count < 0x80000000 && image_tree.depth > 0 && image_tree.depth < 30);
21 image_tree.nodes = xmalloc((1 << image_tree.depth) * sizeof(struct image_node));
22 image_tree.leaves = xmalloc(image_tree.count * sizeof(struct image_leaf));
23 bread(fb, &image_tree.bbox, sizeof(struct image_bbox));
24 bread(fb, image_tree.nodes + 1, ((1 << image_tree.depth) - 1) * sizeof(struct image_node));
25 bread(fb, image_tree.leaves, image_tree.count * sizeof(struct image_leaf));
26 DBG("Search tree with depth %d and %d leaves loaded", image_tree.depth, image_tree.count);
33 DBG("Freeing image search structures");
34 xfree(image_tree.nodes);
35 xfree(image_tree.leaves);