Martin Storsjo : msvcrt: Don't lock the heap in operator_new.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Nov 9 08:34:17 CST 2015


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

Author: Martin Storsjo <martin at martin.st>
Date:   Fri Nov  6 14:51:56 2015 +0200

msvcrt: Don't lock the heap in operator_new.

The native msvcrt/msvcp allow two threads to be calling
the new handler simultaneously.

Signed-off-by: Martin Storsjo <martin at martin.st>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

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

diff --git a/dlls/msvcrt/heap.c b/dlls/msvcrt/heap.c
index 02e69fe..a908846 100644
--- a/dlls/msvcrt/heap.c
+++ b/dlls/msvcrt/heap.c
@@ -131,6 +131,7 @@ void* CDECL MSVCRT_operator_new(MSVCRT_size_t size)
 {
   void *retval;
   int freed;
+  MSVCRT_new_handler_func handler;
 
   do
   {
@@ -141,12 +142,11 @@ void* CDECL MSVCRT_operator_new(MSVCRT_size_t size)
       return retval;
     }
 
-    LOCK_HEAP;
-    if(MSVCRT_new_handler)
-      freed = (*MSVCRT_new_handler)(size);
+    handler = MSVCRT_new_handler;
+    if(handler)
+      freed = (*handler)(size);
     else
       freed = 0;
-    UNLOCK_HEAP;
   } while(freed);
 
   TRACE("(%ld) out of memory\n", size);




More information about the wine-cvs mailing list