+ Fixed bugs in listfile search

This commit is contained in:
Ladislav
2013-12-16 12:18:32 +01:00
parent fe51da468b
commit 60ef0346ba
3 changed files with 41 additions and 17 deletions

View File

@@ -53,14 +53,9 @@ static bool FreeListFileCache(TListFileCache * pCache)
if(pCache == NULL)
return false;
//
// Note: don't close the pCache->hFile handle.
// This has to be done by the creator of the listfile cache
//
// Free all allocated buffers
if(pCache->szMask != NULL)
STORM_FREE(pCache->szMask);
// Close the listfile
if(pCache->hFile != NULL)
SFileCloseFile(pCache->hFile);
STORM_FREE(pCache);
return true;
}
@@ -82,7 +77,7 @@ static TListFileCache * CreateListFileCache(HANDLE hListFile, const char * szMas
nMaskLength = strlen(szMask) + 1;
// Allocate cache for one file block
pCache = (TListFileCache *)STORM_ALLOC(BYTE, sizeof(TListFileCache));
pCache = (TListFileCache *)STORM_ALLOC(BYTE, sizeof(TListFileCache) + nMaskLength);
if(pCache != NULL)
{
// Clear the entire structure
@@ -596,10 +591,6 @@ HANDLE WINAPI SListFileFindFirstFile(HANDLE hMpq, const char * szListFile, const
}
}
// Close the listfile
if(hListFile != NULL)
SFileCloseFile(hListFile);
// Cleanup & exit
if(nError != ERROR_SUCCESS)
{