Module: wine Branch: refs/heads/master Commit: 7b4b4b793059edda89f432551d49703cf3a803dc URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=7b4b4b793059edda89f43255...
Author: Robert Shearman rob@codeweavers.com Date: Sat Dec 31 13:21:19 2005 +0100
wininet: Handle the cache being full better in CommitUrlCacheEntryInternal. Move the freeing of allocation blocks for an entry into URLCache_DeleteEntry. Call URLCache_DeleteEntry to rollback from failure in CommitUrlCacheEntryInternal.
---
dlls/wininet/urlcache.c | 24 ++++++++++++------------ 1 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c index d12bb5a..f143512 100644 --- a/dlls/wininet/urlcache.c +++ b/dlls/wininet/urlcache.c @@ -785,8 +785,17 @@ static BOOL URLCache_FindFirstFreeEntry( * FALSE if it failed * */ -static BOOL URLCache_DeleteEntry(CACHEFILE_ENTRY * pEntry) +static BOOL URLCache_DeleteEntry(LPURLCACHE_HEADER pHeader, CACHEFILE_ENTRY * pEntry) { + DWORD dwStartBlock; + DWORD dwBlock; + BYTE * AllocationTable = (LPBYTE)pHeader + ALLOCATION_TABLE_OFFSET; + + /* update allocation table */ + dwStartBlock = ((DWORD)((BYTE *)pEntry - (BYTE *)pHeader)) / BLOCKSIZE; + for (dwBlock = dwStartBlock; dwBlock < dwStartBlock + pEntry->dwBlocksUsed; dwBlock++) + URLCache_Allocation_BlockFree(AllocationTable, dwBlock); + ZeroMemory(pEntry, pEntry->dwBlocksUsed * BLOCKSIZE); return TRUE; } @@ -2199,6 +2208,7 @@ static BOOL WINAPI CommitUrlCacheEntryIn
if (!URLCache_AddEntryToHash(pHeader, achUrl, (DWORD)((LPBYTE)pUrlEntry - (LPBYTE)pHeader))) { + URLCache_DeleteEntry(pHeader, &pUrlEntry->CacheFileEntry); URLCacheContainer_UnlockIndex(pContainer, pHeader); return FALSE; } @@ -2496,9 +2506,6 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR URLCACHECONTAINER * pContainer; LPURLCACHE_HEADER pHeader; CACHEFILE_ENTRY * pEntry; - DWORD dwStartBlock; - DWORD dwBlock; - BYTE * AllocationTable;
TRACE("(%s)\n", debugstr_a(lpszUrlName));
@@ -2519,14 +2526,7 @@ BOOL WINAPI DeleteUrlCacheEntryA(LPCSTR return FALSE; }
- AllocationTable = (LPBYTE)pHeader + ALLOCATION_TABLE_OFFSET; - - /* update allocation table */ - dwStartBlock = ((DWORD)pEntry - (DWORD)pHeader) / BLOCKSIZE; - for (dwBlock = dwStartBlock; dwBlock < dwStartBlock + pEntry->dwBlocksUsed; dwBlock++) - URLCache_Allocation_BlockFree(AllocationTable, dwBlock); - - URLCache_DeleteEntry(pEntry); + URLCache_DeleteEntry(pHeader, pEntry);
URLCache_DeleteEntryFromHash(pHeader, lpszUrlName);