Haoyang Chen : ole32: Request the needed memory blocks at once.

Alexandre Julliard julliard at winehq.org
Fri Jun 25 16:29:09 CDT 2021


Module: wine
Branch: master
Commit: 542175ab10420953920779f3c64eb310dd3aa258
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=542175ab10420953920779f3c64eb310dd3aa258

Author: Haoyang Chen <chenhaoyang at uniontech.com>
Date:   Wed Jun 23 16:53:39 2021 +0800

ole32: Request the needed memory blocks at once.

When requesting a large block of memory, newNumBlocks can be very large
and time-consuming.

Signed-off-by: Haoyang Chen <chenhaoyang at uniontech.com>
Signed-off-by: Esme Povirk <esme at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/storage32.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 980b6c8d9f6..1bc8455cc6b 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -4144,7 +4144,7 @@ static void StorageImpl_SetNextBlockInChain(
  *
  */
 static ULONG StorageImpl_GetNextFreeBigBlock(
-  StorageImpl* This)
+  StorageImpl* This, ULONG neededAddNumBlocks)
 {
   ULONG depotBlockIndexPos;
   BYTE depotBuffer[MAX_BIG_BLOCK_SIZE];
@@ -4269,7 +4269,7 @@ static ULONG StorageImpl_GetNextFreeBigBlock(
   /*
    * make sure that the block physically exists before using it
    */
-  neededSize.QuadPart = StorageImpl_GetBigBlockOffset(This, freeBlock)+This->bigBlockSize;
+  neededSize.QuadPart = StorageImpl_GetBigBlockOffset(This, freeBlock)+This->bigBlockSize * neededAddNumBlocks;
 
   ILockBytes_Stat(This->lockBytes, &statstg, STATFLAG_NONAME);
 
@@ -7403,7 +7403,7 @@ static BOOL BlockChainStream_Enlarge(BlockChainStream* This,
    */
   if (blockIndex == BLOCK_END_OF_CHAIN)
   {
-    blockIndex = StorageImpl_GetNextFreeBigBlock(This->parentStorage);
+    blockIndex = StorageImpl_GetNextFreeBigBlock(This->parentStorage, 1);
     StorageImpl_SetNextBlockInChain(This->parentStorage,
                                       blockIndex,
                                       BLOCK_END_OF_CHAIN);
@@ -7472,7 +7472,7 @@ static BOOL BlockChainStream_Enlarge(BlockChainStream* This,
   {
     while (oldNumBlocks < newNumBlocks)
     {
-      blockIndex = StorageImpl_GetNextFreeBigBlock(This->parentStorage);
+      blockIndex = StorageImpl_GetNextFreeBigBlock(This->parentStorage, newNumBlocks - oldNumBlocks);
 
       StorageImpl_SetNextBlockInChain(
 	This->parentStorage,




More information about the wine-cvs mailing list