2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #ifndef _STLP_NEW_H_HEADER
20 # define _STLP_NEW_H_HEADER
22 # ifdef _STLP_NO_BAD_ALLOC
23 # ifndef _STLP_NEW_DONT_THROW
24 # define _STLP_NEW_DONT_THROW 1
25 # endif /* _STLP_NEW_DONT_THROW */
32 #if defined(__SYMBIAN32__) && ( defined( __WINSCW__) || defined(__GCCXML__))
34 // already defined symcpp.h included from rvct2_2.h
40 # ifdef _STLP_OWN_IOSTREAMS
42 extern _STLP_DECLSPEC const nothrow_t nothrow;
44 extern IMPORT_C const nothrow_t& GetNoThrowObj();
45 #define nothrow GetNoThrowObj()
48 # define nothrow nothrow_t()
50 #ifndef _STLP_EXCEPTION_BASE
51 # define _STLP_EXCEPTION_BASE exception
54 class bad_alloc : public _STLP_EXCEPTION_BASE {
56 bad_alloc () _STLP_NOTHROW_INHERENTLY { }
57 bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { }
58 bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;}
59 ~bad_alloc () _STLP_NOTHROW_INHERENTLY { }
60 const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; }
65 #endif /* _STLP_NO_BAD_ALLOC */
67 #if defined (_STLP_WINCE)
70 inline void* _STLP_CALL __stl_new(size_t __n) {
74 inline void _STLP_CALL __stl_delete(void* __p) {
84 #else /* _STLP_WINCE */
88 # ifndef _STLP_NO_BAD_ALLOC
89 # ifdef _STLP_USE_OWN_NAMESPACE
92 using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
93 using _STLP_VENDOR_EXCEPT_STD::nothrow_t;
94 using _STLP_VENDOR_EXCEPT_STD::nothrow;
96 # if defined (_STLP_GLOBAL_NEW_HANDLER)
98 using ::set_new_handler;
100 using _STLP_VENDOR_EXCEPT_STD::new_handler;
101 using _STLP_VENDOR_EXCEPT_STD::set_new_handler;
106 # endif /* _STLP_OWN_NAMESPACE */
108 # endif /* _STLP_NO_BAD_ALLOC */
110 # if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW) || defined (__SYMBIAN32__) \
111 || defined (__WINS__) && ! defined (_STLP_CHECK_NULL_ALLOC)
112 # define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){_STLP_THROW(bad_alloc());}return __y
113 # if defined (__SYMBIAN32__)
114 //# define _STLP_NEW operator new
115 #define _STLP_NEW ::malloc
118 # elif defined (__SYMBIAN32__) || defined (__WINS__)
119 # ifndef _STLP_USE_TRAP_LEAVE
120 # define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){abort();}return __y
122 # define _STLP_NEW(x) :: operator new (x, ELeave)
123 # define _STLP_CHECK_NULL_ALLOC(__x) return __x
127 # define _STLP_CHECK_NULL_ALLOC(__x) return __x
131 # define _STLP_NEW ::operator new
133 # define _STLP_PLACEMENT_NEW ::new
135 _STLP_BEGIN_NAMESPACE
139 typedef void(*new_handler)();
141 _STLP_DECLSPEC new_handler set_new_handler(new_handler pnew) __NO_THROW;
145 #if (( defined(__IBMCPP__)|| defined(__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined(__DEBUG_ALLOC__) )
146 inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(_STLP_NEW(__n, __FILE__, __LINE__)); }
147 inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
149 inline void* _STLP_CALL __stl_new(size_t __n) { return ::operator new(__n); }
150 inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); }
155 # endif /* _STLP_WINCE */
157 #if defined(__SYMBIAN32__) && !defined(__GCCE__)
158 _STLP_DECLSPEC void *operator new(unsigned int aSize);
160 _STLP_DECLSPEC void *operator new[](unsigned int aSize);
163 _STLP_DECLSPEC void operator delete(void* aPtr) __NO_THROW;
165 _STLP_DECLSPEC void operator delete[](void* aPtr) __NO_THROW;
167 _STLP_DECLSPEC void* operator new(unsigned int aSize, const std::nothrow_t& /*aNoThrow*/) __NO_THROW;
169 _STLP_DECLSPEC void* operator new[](unsigned int aSize, const std::nothrow_t& aNoThrow) __NO_THROW;
171 _STLP_DECLSPEC void operator delete(void* aPtr, const std::nothrow_t& /*aNoThrow*/) __NO_THROW;
173 _STLP_DECLSPEC void operator delete[](void* aPtr, const std::nothrow_t& /*aNoThrow*/) __NO_THROW;
177 #ifndef __PLACEMENT_VEC_NEW_INLINE
178 #define __PLACEMENT_VEC_NEW_INLINE
179 inline void* operator new[](unsigned int /*aSize*/, void* aBase) __NO_THROW
181 inline void operator delete[](void* /*aPtr*/, void* /*aBase*/) __NO_THROW
187 #ifndef __PLACEMENT_NEW_INLINE
188 #define __PLACEMENT_NEW_INLINE
189 inline void* operator new(unsigned int /*aSize*/, void* aBase) __NO_THROW
192 // Global placement operator delete
193 inline void operator delete(void* /*aPtr*/, void* /*aBase*/) __NO_THROW
195 #endif //__PLACEMENT_NEW_INLINE
198 #endif /* _STLP_NEW_H_HEADER */