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
This commit is contained in:
Spoike 2004-10-02 03:47:24 +00:00
parent 30d0582da8
commit 20e15438ed
1 changed files with 16 additions and 1 deletions

View File

@ -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;