Piotr Caban : wininet: Return error code in URLCache_FindFirstFreeEntry function.

Alexandre Julliard julliard at winehq.org
Fri Apr 6 14:43:24 CDT 2012


Module: wine
Branch: master
Commit: dab1f7c38eaecaf3de38adb75848ecbc93bde11e
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=dab1f7c38eaecaf3de38adb75848ecbc93bde11e

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Thu Apr  5 21:35:46 2012 +0200

wininet: Return error code in URLCache_FindFirstFreeEntry function.

---

 dlls/wininet/urlcache.c |   27 ++++++++++-----------------
 1 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/dlls/wininet/urlcache.c b/dlls/wininet/urlcache.c
index bba81de..5fac89a 100644
--- a/dlls/wininet/urlcache.c
+++ b/dlls/wininet/urlcache.c
@@ -786,11 +786,11 @@ static inline void URLCache_Allocation_BlockAllocate(BYTE * AllocationTable, DWO
  * sets ppEntry to point to it.
  *
  * RETURNS
- *    TRUE if it had enough space
- *    FALSE if it couldn't find enough space
+ *    ERROR_SUCCESS when free memory block was found
+ *    Any other Win32 error code if the entry could not be added
  *
  */
-static BOOL URLCache_FindFirstFreeEntry(URLCACHE_HEADER * pHeader, DWORD dwBlocksNeeded, CACHEFILE_ENTRY ** ppEntry)
+static DWORD URLCache_FindFirstFreeEntry(URLCACHE_HEADER * pHeader, DWORD dwBlocksNeeded, CACHEFILE_ENTRY ** ppEntry)
 {
     LPBYTE AllocationTable = (LPBYTE)pHeader + ALLOCATION_TABLE_OFFSET;
     DWORD dwBlockNumber;
@@ -814,11 +814,11 @@ static BOOL URLCache_FindFirstFreeEntry(URLCACHE_HEADER * pHeader, DWORD dwBlock
             for (index = 0; index < dwBlocksNeeded * BLOCKSIZE / sizeof(DWORD); index++)
                 ((DWORD*)*ppEntry)[index] = 0xdeadbeef;
             (*ppEntry)->dwBlocksUsed = dwBlocksNeeded;
-            return TRUE;
+            return ERROR_SUCCESS;
         }
     }
-    FIXME("Grow file\n");
-    return FALSE;
+
+    return ERROR_HANDLE_DISK_FULL;
 }
 
 /***********************************************************************
@@ -1381,14 +1381,11 @@ static DWORD URLCache_AddEntryToHash(LPURLCACHE_HEADER pHeader, LPCSTR lpszUrl,
  */
 static DWORD URLCache_CreateHashTable(LPURLCACHE_HEADER pHeader, HASH_CACHEFILE_ENTRY *pPrevHash, HASH_CACHEFILE_ENTRY **ppHash)
 {
-    DWORD dwOffset;
+    DWORD dwOffset, error;
     int i;
 
-    if (!URLCache_FindFirstFreeEntry(pHeader, 0x20, (CACHEFILE_ENTRY **)ppHash))
-    {
-        FIXME("no free space for hash table\n");
-        return ERROR_DISK_FULL;
-    }
+    if ((error = URLCache_FindFirstFreeEntry(pHeader, 0x20, (CACHEFILE_ENTRY **)ppHash)) != ERROR_SUCCESS)
+        return error;
 
     dwOffset = (BYTE *)*ppHash - (BYTE *)pHeader;
 
@@ -2755,12 +2752,8 @@ static BOOL CommitUrlCacheEntryInternal(
         dwBytesNeeded += BLOCKSIZE;
     }
 
-    if (!URLCache_FindFirstFreeEntry(pHeader, dwBytesNeeded / BLOCKSIZE, &pEntry))
-    {
-        ERR("no free entries\n");
-        error = ERROR_DISK_FULL;
+    if ((error = URLCache_FindFirstFreeEntry(pHeader, dwBytesNeeded / BLOCKSIZE, &pEntry)) != ERROR_SUCCESS)
         goto cleanup;
-    }
 
     /* FindFirstFreeEntry fills in blocks used */
     pUrlEntry = (URL_CACHEFILE_ENTRY *)pEntry;




More information about the wine-cvs mailing list