summaryrefslogtreecommitdiff
path: root/mpq-fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'mpq-fs.c')
-rw-r--r--mpq-fs.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/mpq-fs.c b/mpq-fs.c
index 160fdcd..c055b17 100644
--- a/mpq-fs.c
+++ b/mpq-fs.c
@@ -28,6 +28,7 @@ static char * strnormalize(char * _str) {
}
htab * hash_table = 0;
+struct st_alloc_t * st = 0;
static void add_file(struct mpq_archive_t * mpq_a, char * fname) {
int entry;
@@ -36,13 +37,15 @@ static void add_file(struct mpq_archive_t * mpq_a, char * fname) {
if ((entry = mpqlib_find_hash_entry_by_name(mpq_a, fname, 0, 0)) < 0)
return;
- if (!hash_table)
+ if (!hash_table) {
hash_table = hcreate(INITIAL_HASH_SIZE);
+ st = st_init();
+ }
- nfname = strnormalize(st_strdup(fname));
+ nfname = strnormalize(st_strdup(st, fname));
hadd(hash_table, (uint8_t *) nfname, strlen(nfname), NULL);
if (!hstuff(hash_table)) {
- hstuff(hash_table) = st_alloc(sizeof(hash_entry));
+ hstuff(hash_table) = st_alloc(st, sizeof(hash_entry));
}
((hash_entry *) hstuff(hash_table))->mpq_a = mpq_a;
((hash_entry *) hstuff(hash_table))->entry = entry;
@@ -155,14 +158,8 @@ int mpqlib_fs_filelist(char * buffer) {
void mpqlib_fs_shutdown() {
if (!hash_table)
return;
-/*
- if (hfirst(hash_table)) do {
- free(hstuff(hash_table));
- free(hkey(hash_table));
- } while (hnext(hash_table));
-*/
- st_shutdown();
+ st_destroy(st);
hdestroy(hash_table);
hash_table = 0;
}