From 03da61a716f7d28dae4a1d88d2a167abd6599f70 Mon Sep 17 00:00:00 2001 From: William Miles Date: Tue, 6 Sep 2022 17:08:57 +1000 Subject: [PATCH] Added comment about RT hash. Fixed memory leak in NavmeshList main. --- NavmeshList/main.c | 4 ++++ espReader/ESPReader.h | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/NavmeshList/main.c b/NavmeshList/main.c index ede5f43..a65a385 100644 --- a/NavmeshList/main.c +++ b/NavmeshList/main.c @@ -31,9 +31,13 @@ int main(void) { espr_decompress(buffer, size, decompressed, dc_size); + free(buffer); + size_t formid_count = espr_formid_count(decompressed, dc_size); printf("FormID Count: %zu\n", formid_count); + free(decompressed); + return 0; } diff --git a/espReader/ESPReader.h b/espReader/ESPReader.h index a955ca3..f97f750 100644 --- a/espReader/ESPReader.h +++ b/espReader/ESPReader.h @@ -3,6 +3,7 @@ /* For reading structured data out of Creation Engine esp/esm files. * Based on information from: * https://en.uesp.net/wiki/Skyrim_Mod:Mod_File_Format + * https://github.com/TES5Edit/TES5Edit * * esp/esm files generally have a tree-like structure where: * - top level is a a TES4 record concatenated with each of the top-level groups @@ -29,6 +30,13 @@ extern "C" { #define RT_SIZE 128 +/* RT hash seed was externally calculated s.t. the fourcc codes perfectly hash into + * indices between 0 and 511. That is, there are no hashing collisions. This allows + * for hard coded lookup tables for the fourcc codes in a relatively small space. + * + * A minimal perfect hash is also possible with an intermediate seed table, though + * I'm not sure which is faster, if it's worth trying to speed this up, etc. + */ #define RT_HASH_SIZE 512 #define RT_HASH_BITS 9 #define RT_HASH_SEED 131261257