Piotr Caban : msvcrt: Use new() for allocations returning BadAlloc exception.

Alexandre Julliard julliard at winehq.org
Wed Aug 18 16:22:10 CDT 2021


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Wed Aug 18 16:08:56 2021 +0200

msvcrt: Use new() for allocations returning BadAlloc exception.

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

---

 dlls/msvcrt/lock.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/dlls/msvcrt/lock.c b/dlls/msvcrt/lock.c
index 74156aa7db3..78767689c06 100644
--- a/dlls/msvcrt/lock.c
+++ b/dlls/msvcrt/lock.c
@@ -23,7 +23,6 @@
 #include "windef.h"
 #include "winbase.h"
 #include "winternl.h"
-#include "wine/heap.h"
 #include "msvcrt.h"
 #include "cppexcept.h"
 #include "mtdll.h"
@@ -921,11 +920,9 @@ int __cdecl event_wait_for_multiple(event **events, size_t count, bool wait_all,
     if(count == 0)
         return 0;
 
-    wait = heap_alloc(FIELD_OFFSET(thread_wait, entries[count]));
-    if(!wait)
-        throw_exception(EXCEPTION_BAD_ALLOC, 0, "bad allocation");
+    wait = operator_new(FIELD_OFFSET(thread_wait, entries[count]));
     ret = evt_wait(wait, events, count, wait_all, timeout);
-    heap_free(wait);
+    operator_delete(wait);
 
     return ret;
 }
@@ -1005,10 +1002,7 @@ bool __thiscall _Condition_variable_wait_for(_Condition_variable *this,
 
     TRACE("(%p %p %d)\n", this, cs, timeout);
 
-    if(!(q = HeapAlloc(GetProcessHeap(), 0, sizeof(cv_queue)))) {
-        throw_exception(EXCEPTION_BAD_ALLOC, 0, "bad allocation");
-    }
-
+    q = operator_new(sizeof(cv_queue));
     critical_section_lock(&this->lock);
     q->next = this->queue;
     q->expired = FALSE;
@@ -1030,7 +1024,7 @@ bool __thiscall _Condition_variable_wait_for(_Condition_variable *this,
             NtWaitForKeyedEvent(keyed_event, q, 0, 0);
     }
 
-    HeapFree(GetProcessHeap(), 0, q);
+    operator_delete(q);
     critical_section_lock(cs);
     return TRUE;
 }




More information about the wine-cvs mailing list