Commit 1c09a7c5 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcp90: Don't use throw_exception helper for bad_alloc exception.

parent 5630ce26
......@@ -65,7 +65,7 @@ void* (__cdecl *MSVCRT_set_new_handler)(void*);
void* __cdecl operator_new(size_t size)
{
void *ret = MSVCRT_operator_new(size);
if (!ret) throw_exception(EXCEPTION_BAD_ALLOC, "bad allocation");
if (!ret) _Xmem();
return ret;
}
......
......@@ -485,3 +485,4 @@ typedef struct {
} complex_double;
void WINAPI DECLSPEC_NORETURN _CxxThrowException(exception*,const cxx_exception_type*);
void __cdecl DECLSPEC_NORETURN _Xmem(void);
......@@ -317,7 +317,6 @@ typedef struct __exception
/* Internal: throws selected exception */
typedef enum __exception_type {
EXCEPTION,
EXCEPTION_BAD_ALLOC,
EXCEPTION_BAD_CAST,
EXCEPTION_LOGIC_ERROR,
EXCEPTION_LENGTH_ERROR,
......
......@@ -89,7 +89,7 @@ void __thiscall _Concurrent_queue_base_v4__Internal_throw_exception(
const _Concurrent_queue_base_v4 *this)
{
TRACE("(%p)\n", this);
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
_Xmem();
}
/* ??0_Concurrent_queue_base_v4@details@Concurrency@@IAE@I@Z */
......
......@@ -867,17 +867,25 @@ DEFINE_RTTI_DATA2(range_error, 0, &runtime_error_rtti_base_descriptor, &exceptio
DEFINE_CXX_DATA2(range_error, &runtime_error_cxx_type_info, &exception_cxx_type_info, MSVCP_runtime_error_dtor)
/* ?_Nomemory@std@@YAXXZ */
void __cdecl _Nomemory(void)
void __cdecl DECLSPEC_NORETURN _Nomemory(void)
{
bad_alloc e;
TRACE("()\n");
throw_exception(EXCEPTION_BAD_ALLOC, "bad allocation");
MSVCP_bad_alloc_default_ctor(&e);
_CxxThrowException(&e, &bad_alloc_cxx_type);
}
/* ?_Xmem@tr1@std@@YAXXZ */
void __cdecl _Xmem(void)
void __cdecl DECLSPEC_NORETURN _Xmem(void)
{
bad_alloc e;
TRACE("()\n");
throw_exception(EXCEPTION_BAD_ALLOC, "bad allocation");
MSVCP_bad_alloc_default_ctor(&e);
_CxxThrowException(&e, &bad_alloc_cxx_type);
}
/* ?_Xinvalid_argument@std@@YAXPBD@Z */
......@@ -1048,11 +1056,6 @@ void throw_exception(exception_type et, const char *str)
MSVCP_exception_ctor(&e, name);
_CxxThrowException(&e, &exception_cxx_type);
}
case EXCEPTION_BAD_ALLOC: {
bad_alloc e;
MSVCP_bad_alloc_ctor(&e, name);
_CxxThrowException(&e, &bad_alloc_cxx_type);
}
case EXCEPTION_BAD_CAST: {
bad_cast e;
MSVCP_bad_cast_ctor(&e, str);
......
......@@ -170,11 +170,7 @@ void __thiscall MSVCP_allocator_wchar_deallocate(void *this,
DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_allocate, 8)
wchar_t* __thiscall MSVCP_allocator_wchar_allocate(void *this, size_t count)
{
if(UINT_MAX/count < sizeof(wchar_t)) {
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
return NULL;
}
if(UINT_MAX/count < sizeof(wchar_t)) _Xmem();
return operator_new(count * sizeof(wchar_t));
}
......@@ -269,11 +265,7 @@ DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_allocate, 8)
unsigned short* __thiscall MSVCP_allocator_short_allocate(
void *this, size_t count)
{
if(UINT_MAX/count < sizeof(unsigned short)) {
throw_exception(EXCEPTION_BAD_ALLOC, NULL);
return NULL;
}
if(UINT_MAX/count < sizeof(unsigned short)) _Xmem();
return operator_new(count * sizeof(unsigned short));
}
......
......@@ -663,4 +663,5 @@ static inline int mbstowcs_wrapper( size_t *ret, wchar_t *wcs, size_t size, cons
#define hypotf( x, y ) ((float)hypot( (double)(x), (double)(y) ))
#endif
void WINAPI _CxxThrowException(exception*,const cxx_exception_type*);
void WINAPI DECLSPEC_NORETURN _CxxThrowException(exception*,const cxx_exception_type*);
void __cdecl DECLSPEC_NORETURN _Xmem(void);
......@@ -94,8 +94,7 @@ void* __cdecl operator_new(size_t size)
} while (freed);
TRACE("(%Iu) out of memory\n", size);
throw_exception(EXCEPTION_BAD_ALLOC, "bad allocation");
return NULL;
_Xmem();
}
void __cdecl operator_delete(void *mem)
......@@ -116,7 +115,7 @@ void* __cdecl operator_new(size_t size)
{
void *ret = MSVCRT_operator_new(size);
#if _MSVCP_VER < 80
if (!ret) throw_exception(EXCEPTION_BAD_ALLOC, "bad allocation");
if (!ret) _Xmem();
#endif
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment