Akihiro Sagawa : kernel32: Don't move fixed memory area in GlobalReAlloc.

Alexandre Julliard julliard at winehq.org
Mon Jun 3 16:06:31 CDT 2013


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

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Sat Jun  1 22:01:41 2013 +0900

kernel32: Don't move fixed memory area in GlobalReAlloc.

---

 dlls/kernel32/heap.c       |    2 ++
 dlls/kernel32/tests/heap.c |   28 ++++++----------------------
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/dlls/kernel32/heap.c b/dlls/kernel32/heap.c
index e0b86e5..51bd235 100644
--- a/dlls/kernel32/heap.c
+++ b/dlls/kernel32/heap.c
@@ -646,6 +646,8 @@ HGLOBAL WINAPI GlobalReAlloc(
       if(ISPOINTER(hmem))
       {
          /* reallocate fixed memory */
+         if (!(flags & GMEM_MOVEABLE))
+            heap_flags |= HEAP_REALLOC_IN_PLACE_ONLY;
          hnew=HeapReAlloc(GetProcessHeap(), heap_flags, hmem, size);
       }
       else
diff --git a/dlls/kernel32/tests/heap.c b/dlls/kernel32/tests/heap.c
index 866abb8..e36336c 100644
--- a/dlls/kernel32/tests/heap.c
+++ b/dlls/kernel32/tests/heap.c
@@ -251,17 +251,9 @@ static void test_heap(void)
         gbl = GlobalAlloc(GMEM_FIXED, init_size);
         SetLastError(MAGIC_DEAD);
         hsecond = GlobalReAlloc(gbl, size + init_size, 0);
-        if (hsecond != gbl) {
-            todo_wine
-            ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-               "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
-            GlobalFree(hsecond);
-        }
-        else {
-            ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-               "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
-            GlobalFree(gbl);
-        }
+        ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
+           "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
+        GlobalFree(gbl);
     }
 
     /* GMEM_FIXED block can be relocated with GMEM_MOVEABLE */
@@ -418,17 +410,9 @@ static void test_heap(void)
         gbl = LocalAlloc(LMEM_FIXED, init_size);
         SetLastError(MAGIC_DEAD);
         hsecond = LocalReAlloc(gbl, size + init_size, 0);
-        if (hsecond != gbl) {
-            todo_wine
-            ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-               "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
-            LocalFree(hsecond);
-        }
-        else {
-            ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
-               "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
-            LocalFree(gbl);
-        }
+        ok(hsecond == gbl || (hsecond == NULL && GetLastError() == ERROR_NOT_ENOUGH_MEMORY),
+           "got %p with %x (expected %p or NULL) @%ld\n", hsecond, GetLastError(), gbl, size);
+        LocalFree(gbl);
     }
 
     /* LMEM_FIXED memory can be relocated with LMEM_MOVEABLE */




More information about the wine-cvs mailing list