|
|
|
| 1 |
|
// new standard header for Microsoft |
| 2 |
|
#pragma once |
| 3 |
|
#ifndef _NEW_ |
| 4 |
|
#define _NEW_ |
| 5 |
|
#ifndef RC_INVOKED |
| 6 |
|
#include <exception> |
| 7 |
|
|
| 8 |
|
#ifdef _MSC_VER |
| 9 |
|
#pragma pack(push,_CRT_PACKING) |
| 10 |
|
#pragma warning(push,3) |
| 11 |
|
#pragma push_macro("new") |
| 12 |
|
#endif /* _MSC_VER */ |
| 13 |
|
|
| 14 |
|
#undef new |
| 15 |
|
|
| 16 |
|
|
| 17 |
|
#if !defined(__CRTDECL) |
| 18 |
|
#if defined(_M_CEE_PURE) |
| 19 |
|
#define __CRTDECL |
| 20 |
|
#else |
| 21 |
|
#define __CRTDECL __cdecl |
| 22 |
|
#endif |
| 23 |
|
#endif |
| 24 |
|
|
| 25 |
|
_STD_BEGIN |
| 26 |
|
|
| 27 |
|
// SUPPORT TYPES |
| 28 |
|
#if !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS) |
| 29 |
|
// handler for operator new failures |
| 30 |
|
#ifdef _M_CEE_PURE |
| 31 |
|
typedef void (__clrcall * new_handler) (); |
| 32 |
|
#else |
| 33 |
|
typedef void (__cdecl * new_handler) (); |
| 34 |
|
#endif |
| 35 |
|
#endif /* !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS) */ |
| 36 |
|
|
| 37 |
|
#ifndef __NOTHROW_T_DEFINED |
| 38 |
|
struct nothrow_t |
| 39 |
|
{ // placement new tag type to suppress exceptions |
| 40 |
|
}; |
| 51 |
|
void __CRTDECL operator delete(void *) _THROW0(); |
| 52 |
|
#pragma warning (suppress: 4985) |
| 53 |
|
_Ret_bytecap_(_Size) void *__CRTDECL operator new(size_t _Size) _THROW1(std::bad_alloc); |
| 54 |
|
|
| 55 |
|
#ifndef __PLACEMENT_NEW_INLINE |
| 56 |
|
#define __PLACEMENT_NEW_INLINE |
| 57 |
|
inline void *__CRTDECL operator new(size_t, void *_Where) _THROW0() |
| 58 |
|
{ // construct array with placement at _Where |
| 59 |
|
return (_Where); |
| 60 |
|
} |
| 61 |
|
|
| 62 |
|
inline void __CRTDECL operator delete(void *, void *) _THROW0() |
| 63 |
|
{ // delete if placement new fails |
| 64 |
|
} |
| 65 |
|
#endif /* __PLACEMENT_NEW_INLINE */ |
| 66 |
|
|
| 67 |
|
#ifndef __PLACEMENT_VEC_NEW_INLINE |
| 68 |
|
#define __PLACEMENT_VEC_NEW_INLINE |
| 69 |
|
inline void *__CRTDECL operator new[](size_t, void *_Where) _THROW0() |
| 70 |
|
{ // construct array with placement at _Where |
| 71 |
|
return (_Where); |
| 72 |
|
} |
| 73 |
|
|
| 74 |
|
inline void __CRTDECL operator delete[](void *, void *) _THROW0() |
| 75 |
|
{ // delete if placement array new fails |
| 76 |
|
} |
| 77 |
|
#endif /* __PLACEMENT_VEC_NEW_INLINE */ |
| 78 |
|
|
| 79 |
|
void __CRTDECL operator delete[](void *) _THROW0(); // delete allocated array |
| 80 |
|
|
| 81 |
|
_Ret_bytecap_(_Size) void *__CRTDECL operator new[](size_t _Size) |
| 82 |
|
_THROW1(std::bad_alloc); // allocate array or throw exception |
| 83 |
|
|
| 84 |
|
#ifndef __NOTHROW_T_DEFINED |
| 85 |
|
#define __NOTHROW_T_DEFINED |
| 86 |
|
_Ret_opt_bytecap_(_Size) void *__CRTDECL operator new(size_t _Size, const std::nothrow_t&) |
| 87 |
|
_THROW0(); |
| 88 |
|
|
| 89 |
|
_Ret_opt_bytecap_(_Size) void *__CRTDECL operator new[](size_t _Size, const std::nothrow_t&) |
| 90 |
|
_THROW0(); // allocate array or return null pointer |
| 91 |
|
|
| 92 |
|
void __CRTDECL operator delete(void *, const std::nothrow_t&) |
| 93 |
|
_THROW0(); // delete if nothrow new fails -- REPLACEABLE |
| 94 |
|
|
| 95 |
|
void __CRTDECL operator delete[](void *, const std::nothrow_t&) |
| 96 |
|
_THROW0(); // delete if nothrow array new fails -- REPLACEABLE |
| 97 |
|
#endif /* __NOTHROW_T_DEFINED */ |
| 98 |
|
|
| 99 |
|
|
| 100 |
|
#if !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS) |
| 101 |
|
using std::new_handler; |
| 102 |
|
#endif /* !defined(_INC_NEW) || !defined(_MSC_EXTENSIONS) */ |
| 103 |
|
|
| 104 |
|
#ifdef _MSC_VER |
| 105 |
|
#pragma pop_macro("new") |
| 106 |
|
#pragma warning(pop) |
| 107 |
|
#pragma pack(pop) |
| 108 |
|
#endif /* _MSC_VER */ |
| 109 |
|
|
| 110 |
|
#endif /* RC_INVOKED */ |
| 111 |
|
#endif /* _NEW_ */ |
| 112 |
|
|
| 113 |
|
/* |
| 114 |
|
* Copyright (c) 1992-2007 by P.J. Plauger. ALL RIGHTS RESERVED. |
| 115 |
|
* Consult your license regarding permissions and restrictions. |
| 116 |
|
V5.03:0009 */ |
| 117 |
|
|
|
|
|