Use 32-bit offsets in the string pool search tree to reduce its size

This commit is contained in:
Eric Fischer
2017-09-06 15:26:19 -07:00
parent 0f8b32c69f
commit 764a8ac17c
5 changed files with 20 additions and 6 deletions
+11 -1
View File
@@ -35,7 +35,7 @@ int swizzlecmp(const char *a, const char *b) {
}
long long addpool(struct memfile *poolfile, struct memfile *treefile, const char *s, char type) {
long long *sp = &treefile->tree;
unsigned long *sp = &treefile->tree;
size_t depth = 0;
// In typical data, traversal depth generally stays under 2.5x
@@ -95,6 +95,16 @@ long long addpool(struct memfile *poolfile, struct memfile *treefile, const char
exit(EXIT_FAILURE);
}
if (off >= LONG_MAX || treefile->off >= LONG_MAX) {
// Tree or pool is bigger than 2GB
static bool warned = false;
if (!warned) {
fprintf(stderr, "Warning: string pool is very large.\n");
warned = true;
}
return off;
}
struct stringpool tsp;
tsp.left = 0;
tsp.right = 0;