mirror of
https://github.com/Chuyu-Team/VC-LTL5.git
synced 2026-10-21 07:55:48 +08:00
61 lines
1.4 KiB
C++
61 lines
1.4 KiB
C++
//
|
|
// std_exception.cpp
|
|
//
|
|
// Copyright (c) Microsoft Corporation. All rights reserved.
|
|
//
|
|
// Definitions of the std::exception implementation functions.
|
|
//
|
|
#include <vcruntime_exception.h>
|
|
#include <vcruntime_internal.h>
|
|
#include <framework.h>
|
|
|
|
#if WindowsTargetPlatformMinVersion < __MakeVersion(10, 0, 10240)
|
|
extern "C" void __cdecl __std_exception_copy(
|
|
__std_exception_data const* const from,
|
|
__std_exception_data* const to
|
|
)
|
|
{
|
|
_ASSERTE(to->_What == nullptr && to->_DoFree == false);
|
|
|
|
if (!from->_DoFree || !from->_What)
|
|
{
|
|
to->_What = from->_What;
|
|
to->_DoFree = false;
|
|
return;
|
|
}
|
|
|
|
size_t const buffer_count = strlen(from->_What) + 1;
|
|
|
|
__crt_unique_heap_ptr<char, __crt_public_free_policy> buffer(static_cast<char*>(malloc(buffer_count)));
|
|
if (!buffer)
|
|
{
|
|
return;
|
|
}
|
|
|
|
strcpy_s(buffer.get(), buffer_count, from->_What);
|
|
to->_What = buffer.detach();
|
|
to->_DoFree = true;
|
|
}
|
|
|
|
_LCRT_DEFINE_IAT_SYMBOL(__std_exception_copy);
|
|
|
|
#endif
|
|
|
|
#if WindowsTargetPlatformMinVersion < __MakeVersion(10, 0, 10240)
|
|
extern "C" void __cdecl __std_exception_destroy(
|
|
__std_exception_data* const data
|
|
)
|
|
{
|
|
if (data->_DoFree)
|
|
{
|
|
free(const_cast<char*>(data->_What));
|
|
}
|
|
|
|
data->_DoFree = false;
|
|
data->_What = nullptr;
|
|
}
|
|
|
|
_LCRT_DEFINE_IAT_SYMBOL(__std_exception_destroy);
|
|
|
|
#endif
|