msvcrt: Simplify throw_exception helper.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2021-08-20 18:45:08 +02:00 committed by Alexandre Julliard
parent 1c9a30f217
commit 5e3f959aed
3 changed files with 6 additions and 13 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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);