Piotr Caban : msvcrt: Simplify throw_exception helper.

Alexandre Julliard julliard at winehq.org
Fri Aug 20 16:12:56 CDT 2021


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

Author: Piotr Caban <piotr at codeweavers.com>
Date:   Fri Aug 20 18:45:08 2021 +0200

msvcrt: Simplify throw_exception helper.

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

---

 dlls/msvcrt/cpp.c    | 12 ++++--------
 dlls/msvcrt/heap.c   |  2 +-
 dlls/msvcrt/msvcrt.h |  5 +----
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/dlls/msvcrt/cpp.c b/dlls/msvcrt/cpp.c
index 12a38bb2407..72abcfe055f 100644
--- a/dlls/msvcrt/cpp.c
+++ b/dlls/msvcrt/cpp.c
@@ -616,15 +616,11 @@ void msvcrt_init_exception(void *base)
 }
 
 #if _MSVCR_VER >= 80
-void throw_exception(exception_type et, HRESULT hr, const char *str)
+void throw_bad_alloc(void)
 {
-    switch(et) {
-    case EXCEPTION_BAD_ALLOC: {
-        bad_alloc e;
-        __exception_ctor(&e, str, &bad_alloc_vtable);
-        _CxxThrowException(&e, &bad_alloc_exception_type);
-    }
-    }
+    bad_alloc e;
+    __exception_ctor(&e, "bad allocation", &bad_alloc_vtable);
+    _CxxThrowException(&e, &bad_alloc_exception_type);
 }
 #endif
 
diff --git a/dlls/msvcrt/heap.c b/dlls/msvcrt/heap.c
index b74a759227a..429a9e2ecda 100644
--- a/dlls/msvcrt/heap.c
+++ b/dlls/msvcrt/heap.c
@@ -156,7 +156,7 @@ void* CDECL DECLSPEC_HOTPATCH operator_new(size_t size)
 
   TRACE("(%Iu) out of memory\n", size);
 #if _MSVCR_VER >= 80
-  throw_exception(EXCEPTION_BAD_ALLOC, 0, "bad allocation");
+  throw_bad_alloc();
 #endif
   return NULL;
 }
diff --git a/dlls/msvcrt/msvcrt.h b/dlls/msvcrt/msvcrt.h
index 4e8f917112b..60f8c2f5ef2 100644
--- a/dlls/msvcrt/msvcrt.h
+++ b/dlls/msvcrt/msvcrt.h
@@ -187,10 +187,7 @@ extern WORD *MSVCRT__pwctype;
 
 void msvcrt_set_errno(int) DECLSPEC_HIDDEN;
 #if _MSVCR_VER >= 80
-typedef enum {
-    EXCEPTION_BAD_ALLOC,
-} exception_type;
-void throw_exception(exception_type, HRESULT, const char*) DECLSPEC_HIDDEN;
+void throw_bad_alloc(void) DECLSPEC_HIDDEN;
 #endif
 
 void __cdecl _purecall(void);




More information about the wine-cvs mailing list