Huw Davies : ole32: In simple mode keep the stream size above the small block limit.

Alexandre Julliard julliard at winehq.org
Tue Jun 2 08:44:31 CDT 2009


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Mon Jun  1 11:36:19 2009 +0100

ole32: In simple mode keep the stream size above the small block limit.

---

 dlls/ole32/stg_stream.c      |    4 ++++
 dlls/ole32/tests/storage32.c |   24 ++++++++++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/dlls/ole32/stg_stream.c b/dlls/ole32/stg_stream.c
index 3fde160..9acd414 100644
--- a/dlls/ole32/stg_stream.c
+++ b/dlls/ole32/stg_stream.c
@@ -575,6 +575,10 @@ static HRESULT WINAPI StgStreamImpl_SetSize(
     return STG_E_ACCESSDENIED;
   }
 
+  /* In simple mode keep the stream size above the small block limit */
+  if (This->parentStorage->ancestorStorage->base.openFlags & STGM_SIMPLE)
+    libNewSize.u.LowPart = max(libNewSize.u.LowPart, LIMIT_TO_USE_SMALL_BLOCK);
+
   if (This->streamSize.u.LowPart == libNewSize.u.LowPart)
     return S_OK;
 
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index fa5d46c..438913c 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -1354,6 +1354,7 @@ static void test_simple(void)
     HRESULT r;
     IStream *stm;
     static const WCHAR stmname[] = { 'C','O','N','T','E','N','T','S',0 };
+    static const WCHAR stmname2[] = { 'S','m','a','l','l',0 };
     LARGE_INTEGER pos;
     ULARGE_INTEGER upos;
     DWORD count;
@@ -1400,6 +1401,19 @@ static void test_simple(void)
 
     IStream_Release(stm);
 
+    r = IStorage_CreateStream(stg, stmname2, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm);
+    ok(r == S_OK, "got %08x\n", r);
+
+    upos.QuadPart = 100;
+    r = IStream_SetSize(stm, upos);
+    ok(r == S_OK, "got %08x\n", r);
+
+    r = IStream_Write(stm, "foo", 3, &count);
+    ok(r == S_OK, "got %08x\n", r);
+    ok(count == 3, "got %d\n", count);
+
+    IStream_Release(stm);
+
     IStorage_Commit(stg, STGC_DEFAULT);
     IStorage_Release(stg);
 
@@ -1415,6 +1429,16 @@ static void test_simple(void)
 
     IStream_Release(stm);
 
+    r = IStorage_OpenStream(stg, stmname2, NULL, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stm);
+    ok(r == S_OK, "got %08x\n", r);
+
+    r = IStream_Stat(stm, &stat, STATFLAG_NONAME);
+    ok(r == S_OK, "got %08x\n", r);
+    ok(stat.cbSize.QuadPart == 4096, "got %d\n", stat.cbSize.u.LowPart);
+
+    IStream_Release(stm);
+
+
     IStorage_Release(stg);
 
     DeleteFileW(filename);




More information about the wine-cvs mailing list