stdhndlr.cpp
来自「C语言库函数的原型,有用的拿去」· C++ 代码 · 共 40 行
CPP
40 行
// handler.cpp -- set_new_handler for Microsoft
#include <new>
typedef int (__cdecl *new_hand)(size_t);
new_hand __cdecl _set_new_handler(new_hand);
_STD_BEGIN
static new_handler _New_handler;
int __cdecl _New_handler_interface(size_t) _THROW1(std::bad_alloc)
{ // interface to existing Microsoft _callnewh mechanism
_New_handler();
return (1);
}
_CRTIMP2 new_handler __cdecl set_new_handler(new_handler pnew) _THROW0()
{ // remove current handler
_BEGIN_LOCK(_LOCK_MALLOC) // lock thread to ensure atomicity
new_handler pold = _New_handler;
_New_handler = pnew;
_set_new_handler(pnew ? _New_handler_interface : 0);
return (pold);
_END_LOCK()
}
new_handler _CRTIMP2 __cdecl set_new_handler
(
int pnh
) throw()
{
return set_new_handler(static_cast<new_handler>(NULL));
}
_STD_END
/*
* Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V5.03:0009 */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?