From 20e15438edcd0a0a2055420ba9913874f2e5b897 Mon Sep 17 00:00:00 2001 From: Spoike Date: Sat, 2 Oct 2004 03:47:24 +0000 Subject: [PATCH] better fs_cache handling (as in no mem leak...) git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@284 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/common/common.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/engine/common/common.c b/engine/common/common.c index b03c162e2..927a13447 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -2281,7 +2281,22 @@ void FS_RebuildFSHash(void) filesystemhash.bucket = BZ_Malloc(Hash_BytesForBuckets(filesystemhash.numbuckets)); } else - memset(filesystemhash.bucket, 0, Hash_BytesForBuckets(filesystemhash.numbuckets)); + { + bucket_t *bucket, *next; + + for (i = 0; i < filesystemhash.numbuckets; i++) + { + bucket = filesystemhash.bucket[i]; + filesystemhash.bucket[i] = NULL; + while(bucket) + { + next = bucket->next; + if (bucket->keystring == (char*)(bucket+1)) + Z_Free(bucket); + bucket = next; + } + } + } Hash_InitTable(&filesystemhash, filesystemhash.numbuckets, filesystemhash.bucket); fs_hash_dups = 0;