STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
new.h
Go to the documentation of this file.
1 
2 /***
3 *new.h - declarations and definitions for C++ memory allocation functions
4 *
5 * Copyright (c) Microsoft Corporation. All rights reserved.
6 *
7 *Purpose:
8 * Contains the declarations for C++ memory allocation functions.
9 *
10 * [Public]
11 *
12 ****/
13 
14 #pragma once
15 
16 #ifndef _INC_NEW
17 #define _INC_NEW
18 
19 #ifdef __cplusplus
20 
21 #ifndef _MSC_EXTENSIONS
22 #include <new>
23 #endif /* _MSC_EXTENSIONS */
24 
25 #include <crtdefs.h>
26 
27 /* Protect against #define of new */
28 #pragma push_macro("new")
29 #undef new
30 
31 #ifdef _CRTBLD
32 #ifndef _USE_OLD_STDCPP
33 /* Define _CRTIMP2 */
34 #ifndef _CRTIMP2
35 #if defined (CRTDLL2)
36 #define _CRTIMP2 __declspec(dllexport)
37 #else /* defined (CRTDLL2) */
38 #if defined (_DLL) && !defined (_STATIC_CPPLIB)
39 #define _CRTIMP2 __declspec(dllimport)
40 #else /* defined (_DLL) && !defined (_STATIC_CPPLIB) */
41 #define _CRTIMP2
42 #endif /* defined (_DLL) && !defined (_STATIC_CPPLIB) */
43 #endif /* defined (CRTDLL2) */
44 #endif /* _CRTIMP2 */
45 #endif /* _USE_OLD_STDCPP */
46 #else /* _CRTBLD */
47 /* Define _CRTIMP2 */
48 #ifndef _CRTIMP2
49 #if defined (_DLL) && !defined (_STATIC_CPPLIB)
50 #define _CRTIMP2 __declspec(dllimport)
51 #else /* defined (_DLL) && !defined (_STATIC_CPPLIB) */
52 #define _CRTIMP2
53 #endif /* defined (_DLL) && !defined (_STATIC_CPPLIB) */
54 #endif /* _CRTIMP2 */
55 #endif /* _CRTBLD */
56 
57 #ifdef _MSC_EXTENSIONS
58 #if defined (_USE_OLD_STDCPP) && defined (_CRTBLD)
59 typedef void (__cdecl * new_handler) ();
60 _CRTIMP new_handler __cdecl set_new_handler(_In_opt_ new_handler _NewHandler);
61 #else /* defined (_USE_OLD_STDCPP) && defined (_CRTBLD) */
62 
63 namespace std {
64 
65 #ifdef _M_CEE_PURE
66 typedef void (__clrcall * new_handler) ();
67 #else /* _M_CEE_PURE */
68 typedef void (__cdecl * new_handler) ();
69 #endif /* _M_CEE_PURE */
70 #ifdef _M_CEE
71 typedef void (__clrcall * _new_handler_m) ();
72 #endif /* _M_CEE */
73 _CRTIMP2 new_handler __cdecl set_new_handler(_In_opt_ new_handler _NewHandler) throw();
74 };
75 
76 #ifdef _M_CEE
77 using std::_new_handler_m;
78 #endif /* _M_CEE */
79 using std::new_handler;
81 #endif /* defined (_USE_OLD_STDCPP) && defined (_CRTBLD) */
82 #endif /* _MSC_EXTENSIONS */
83 
84 #ifndef __NOTHROW_T_DEFINED
85 #define __NOTHROW_T_DEFINED
86 namespace std {
87  /* placement new tag type to suppress exceptions */
88  struct nothrow_t {};
89 
90  /* constant for placement new tag */
91  extern const nothrow_t nothrow;
92 };
93 
94 _Ret_maybenull_ _Post_writable_byte_size_(_Size) void *__CRTDECL operator new(size_t _Size, const std::nothrow_t&) throw();
95 _Ret_maybenull_ _Post_writable_byte_size_(_Size) void *__CRTDECL operator new[](size_t _Size, const std::nothrow_t&) throw();
96 void __CRTDECL operator delete(void *, const std::nothrow_t&) throw();
97 void __CRTDECL operator delete[](void *, const std::nothrow_t&) throw();
98 #endif /* __NOTHROW_T_DEFINED */
99 
100 #ifndef __PLACEMENT_NEW_INLINE
101 #define __PLACEMENT_NEW_INLINE
102 inline void *__CRTDECL operator new(size_t, void *_Where)
103  {return (_Where); }
104 inline void __CRTDECL operator delete(void *, void *)
105  {return; }
106 #endif /* __PLACEMENT_NEW_INLINE */
107 
108 
109 /*
110  * new mode flag -- when set, makes malloc() behave like new()
111  */
112 
113 _CRTIMP int __cdecl _query_new_mode( void );
114 _CRTIMP int __cdecl _set_new_mode( _In_ int _NewMode);
115 
116 #ifndef _PNH_DEFINED
117 #ifdef _M_CEE_PURE
118 typedef int (__clrcall * _PNH)( size_t );
119 #else /* _M_CEE_PURE */
120 typedef int (__cdecl * _PNH)( size_t );
121 #endif /* _M_CEE_PURE */
122 #define _PNH_DEFINED
123 #endif /* _PNH_DEFINED */
124 
125 _CRTIMP _PNH __cdecl _query_new_handler( void );
126 _CRTIMP _PNH __cdecl _set_new_handler( _In_opt_ _PNH _NewHandler);
127 
128 #pragma pop_macro("new")
129 
130 #endif /* __cplusplus */
131 
132 #endif /* _INC_NEW */
#define _CRTIMP
Definition: crtdefs.h:23
#define _Ret_maybenull_
Definition: sal.h:535
_W64 unsigned int size_t
Definition: crtdefs.h:496
_CRTIMP _In_opt_z_ const wchar_t _In_opt_z_ const wchar_t unsigned int
Definition: crtdefs.h:642
typedef void(__cdecl *_se_translator_function)(unsigned int
STL namespace.
Definition: new:36
#define _In_
Definition: sal.h:314
#define _In_opt_
Definition: sal.h:315
#define __CRTDECL
Definition: crtdefs.h:622
#define _CRTIMP2
Definition: crtdefs.h:126
#define _Post_writable_byte_size_(size)
Definition: sal.h:658
_CRTIMP2 new_handler __cdecl set_new_handler(_In_opt_ new_handler) _THROW0()
_Check_return_ _In_ long _Size
Definition: io.h:325
const nothrow_t nothrow