1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/stdapis/stlportv5/stl/_new.h Wed Mar 31 12:27:01 2010 +0100
1.3 @@ -0,0 +1,208 @@
1.4 +/*
1.5 +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
1.6 +
1.7 +* Redistribution and use in source and binary forms, with or without
1.8 +* modification, are permitted provided that the following conditions are met:
1.9 +
1.10 +* Redistributions of source code must retain the above copyright notice, this
1.11 +* list of conditions and the following disclaimer.
1.12 +* Redistributions in binary form must reproduce the above copyright notice,
1.13 +* this list of conditions and the following disclaimer in the documentation
1.14 +* and/or other materials provided with the distribution.
1.15 +* Neither the name of Nokia Corporation nor the names of its contributors
1.16 +* may be used to endorse or promote products derived from this software
1.17 +* without specific prior written permission.
1.18 +
1.19 +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
1.20 +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1.21 +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1.22 +* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
1.23 +* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
1.24 +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
1.25 +* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
1.26 +* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
1.27 +* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1.28 +* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1.29 +*
1.30 +* Description:
1.31 +*
1.32 +*/
1.33 +
1.34 +#ifndef _STLP_NEW_H_HEADER
1.35 +# define _STLP_NEW_H_HEADER
1.36 +
1.37 +# ifdef _STLP_NO_BAD_ALLOC
1.38 +# ifndef _STLP_NEW_DONT_THROW
1.39 +# define _STLP_NEW_DONT_THROW 1
1.40 +# endif /* _STLP_NEW_DONT_THROW */
1.41 +
1.42 +# include <exception>
1.43 +
1.44 +
1.45 +_STLP_BEGIN_NAMESPACE
1.46 +
1.47 +#if defined(__SYMBIAN32__) && defined( __WINSCW__)
1.48 +// already defined symcpp.h included from rvct2_2.h
1.49 +struct nothrow_t {};
1.50 +#endif
1.51 +
1.52 +
1.53 +# ifdef _STLP_OWN_IOSTREAMS
1.54 +#ifdef __ARMCC__
1.55 +extern _STLP_DECLSPEC const nothrow_t nothrow;
1.56 +#else
1.57 +extern IMPORT_C const nothrow_t& GetNoThrowObj();
1.58 +#define nothrow GetNoThrowObj()
1.59 +#endif
1.60 +# else
1.61 +# define nothrow nothrow_t()
1.62 +# endif
1.63 +#ifndef _STLP_EXCEPTION_BASE
1.64 +# define _STLP_EXCEPTION_BASE exception
1.65 +#endif
1.66 +
1.67 +class bad_alloc : public _STLP_EXCEPTION_BASE {
1.68 +public:
1.69 + bad_alloc () _STLP_NOTHROW_INHERENTLY { }
1.70 + bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { }
1.71 + bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;}
1.72 + ~bad_alloc () _STLP_NOTHROW_INHERENTLY { }
1.73 + const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; }
1.74 +};
1.75 +
1.76 +_STLP_END_NAMESPACE
1.77 +
1.78 +#endif /* _STLP_NO_BAD_ALLOC */
1.79 +
1.80 +#if defined (_STLP_WINCE)
1.81 +_STLP_BEGIN_NAMESPACE
1.82 +
1.83 +inline void* _STLP_CALL __stl_new(size_t __n) {
1.84 + return ::malloc(__n);
1.85 +}
1.86 +
1.87 +inline void _STLP_CALL __stl_delete(void* __p) {
1.88 + free(__p);
1.89 +}
1.90 +
1.91 +#ifndef __cdecl
1.92 +# define __cdecl
1.93 +#endif
1.94 +
1.95 +_STLP_END_NAMESPACE
1.96 +
1.97 +#else /* _STLP_WINCE */
1.98 +
1.99 +#include <new>
1.100 +
1.101 +# ifndef _STLP_NO_BAD_ALLOC
1.102 +# ifdef _STLP_USE_OWN_NAMESPACE
1.103 +
1.104 + _STLP_BEGIN_NAMESPACE
1.105 + using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
1.106 + using _STLP_VENDOR_EXCEPT_STD::nothrow_t;
1.107 + using _STLP_VENDOR_EXCEPT_STD::nothrow;
1.108 +
1.109 +# if defined (_STLP_GLOBAL_NEW_HANDLER)
1.110 + using ::new_handler;
1.111 + using ::set_new_handler;
1.112 +# else
1.113 + using _STLP_VENDOR_EXCEPT_STD::new_handler;
1.114 + using _STLP_VENDOR_EXCEPT_STD::set_new_handler;
1.115 +# endif
1.116 +
1.117 + _STLP_END_NAMESPACE
1.118 +
1.119 +# endif /* _STLP_OWN_NAMESPACE */
1.120 +
1.121 +# endif /* _STLP_NO_BAD_ALLOC */
1.122 +
1.123 +# if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW) || defined (__SYMBIAN32__) \
1.124 + || defined (__WINS__) && ! defined (_STLP_CHECK_NULL_ALLOC)
1.125 +# define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){_STLP_THROW(bad_alloc());}return __y
1.126 +# if defined (__SYMBIAN32__)
1.127 +//# define _STLP_NEW operator new
1.128 +#define _STLP_NEW ::malloc
1.129 +#endif
1.130 +/*
1.131 +# elif defined (__SYMBIAN32__) || defined (__WINS__)
1.132 +# ifndef _STLP_USE_TRAP_LEAVE
1.133 +# define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x;if (__y == 0){abort();}return __y
1.134 +# else
1.135 +# define _STLP_NEW(x) :: operator new (x, ELeave)
1.136 +# define _STLP_CHECK_NULL_ALLOC(__x) return __x
1.137 +# endif
1.138 +*/
1.139 +# else
1.140 +# define _STLP_CHECK_NULL_ALLOC(__x) return __x
1.141 +# endif
1.142 +
1.143 +#ifndef _STLP_NEW
1.144 +# define _STLP_NEW ::operator new
1.145 +#endif
1.146 +# define _STLP_PLACEMENT_NEW ::new
1.147 +
1.148 +_STLP_BEGIN_NAMESPACE
1.149 +
1.150 +#ifdef __SYMBIAN32__
1.151 +
1.152 +typedef void(*new_handler)();
1.153 +
1.154 +_STLP_DECLSPEC new_handler set_new_handler(new_handler pnew) throw();
1.155 +
1.156 +#endif
1.157 +
1.158 +#if (( defined(__IBMCPP__)|| defined(__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined(__DEBUG_ALLOC__) )
1.159 +inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(_STLP_NEW(__n, __FILE__, __LINE__)); }
1.160 +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
1.161 +#else
1.162 +inline void* _STLP_CALL __stl_new(size_t __n) { return ::operator new(__n); }
1.163 +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); }
1.164 +#endif
1.165 +_STLP_END_NAMESPACE
1.166 +
1.167 +
1.168 +# endif /* _STLP_WINCE */
1.169 +
1.170 +#if defined(__SYMBIAN32__) && !defined(__GCCE__)
1.171 +_STLP_DECLSPEC void *operator new(unsigned int aSize);
1.172 +
1.173 +_STLP_DECLSPEC void *operator new[](unsigned int aSize);
1.174 +#endif
1.175 +
1.176 +_STLP_DECLSPEC void operator delete(void* aPtr) throw();
1.177 +
1.178 +_STLP_DECLSPEC void operator delete[](void* aPtr) throw();
1.179 +
1.180 +_STLP_DECLSPEC void* operator new(unsigned int aSize, const std::nothrow_t& /*aNoThrow*/) throw();
1.181 +
1.182 +_STLP_DECLSPEC void* operator new[](unsigned int aSize, const std::nothrow_t& aNoThrow) throw();
1.183 +
1.184 +_STLP_DECLSPEC void operator delete(void* aPtr, const std::nothrow_t& /*aNoThrow*/) throw();
1.185 +
1.186 +_STLP_DECLSPEC void operator delete[](void* aPtr, const std::nothrow_t& /*aNoThrow*/) throw();
1.187 +
1.188 +
1.189 +// placement delete
1.190 +#ifndef __PLACEMENT_VEC_NEW_INLINE
1.191 +#define __PLACEMENT_VEC_NEW_INLINE
1.192 +inline void* operator new[](unsigned int /*aSize*/, void* aBase) throw()
1.193 + {return aBase;}
1.194 +inline void operator delete[](void* /*aPtr*/, void* /*aBase*/) throw()
1.195 + {
1.196 +
1.197 + }
1.198 +#endif
1.199 +
1.200 +#ifndef __PLACEMENT_NEW_INLINE
1.201 +#define __PLACEMENT_NEW_INLINE
1.202 +inline void* operator new(unsigned int /*aSize*/, void* aBase) throw()
1.203 + {return aBase;}
1.204 +
1.205 +// Global placement operator delete
1.206 +inline void operator delete(void* /*aPtr*/, void* /*aBase*/) throw()
1.207 + {}
1.208 +#endif //__PLACEMENT_NEW_INLINE
1.209 +
1.210 +
1.211 +#endif /* _STLP_NEW_H_HEADER */