1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/epoc32/include/tools/stlport/stl/_new.h Wed Mar 31 12:33:34 2010 +0100
1.3 @@ -0,0 +1,161 @@
1.4 +/*
1.5 + * Copyright (c) 1999
1.6 + * Boris Fomitchev
1.7 + *
1.8 + * This material is provided "as is", with absolutely no warranty expressed
1.9 + * or implied. Any use is at your own risk.
1.10 + *
1.11 + * Permission to use or copy this software for any purpose is hereby granted
1.12 + * without fee, provided the above notices are retained on all copies.
1.13 + * Permission to modify the code and to distribute modified code is granted,
1.14 + * provided the above notices are retained, and a notice that the code was
1.15 + * modified is included with the above copyright notice.
1.16 + *
1.17 + */
1.18 +
1.19 +#ifndef _STLP_INTERNAL_NEW
1.20 +#define _STLP_INTERNAL_NEW
1.21 +
1.22 +#ifndef _STLP_INTERNAL_CSTDDEF
1.23 +// size_t
1.24 +# include <stl/_cstddef.h>
1.25 +#endif
1.26 +
1.27 +#if defined (__BORLANDC__) && (__BORLANDC__ < 0x580)
1.28 +// new.h uses ::malloc ;(
1.29 +# include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
1.30 +using _STLP_VENDOR_CSTD::malloc;
1.31 +#endif
1.32 +
1.33 +#if !defined (_STLP_NO_NEW_NEW_HEADER)
1.34 +# if defined (_STLP_BROKEN_BAD_ALLOC_CLASS)
1.35 +# define bad_alloc _STLP_NULLIFIED_BROKEN_BAD_ALLOC_CLASS
1.36 +# define nothrow_t _STLP_NULLIFIED_BROKEN_BAD_NOTHROW_T_CLASS
1.37 +# define nothrow _STLP_NULLIFIED_BROKEN_BAD_NOTHROW
1.38 +# endif
1.39 +
1.40 +// eMbedded Visual C++ .NET unfortunately uses _INC_NEW for both <new.h> and <new>
1.41 +// we undefine the symbol to get the stuff in the SDK's <new>
1.42 +# if defined (_STLP_WCE_NET) && defined (_INC_NEW)
1.43 +# undef _INC_NEW
1.44 +# endif
1.45 +
1.46 +# if defined (new)
1.47 +/* STLport cannot replace native Std library new header if new is a macro,
1.48 + * please define new macro after <new> header inclusion.
1.49 + */
1.50 +# error Cannot include native new header as new is a macro.
1.51 +# endif
1.52 +
1.53 +# include _STLP_NATIVE_CPP_RUNTIME_HEADER(new)
1.54 +
1.55 +# if defined (_STLP_BROKEN_BAD_ALLOC_CLASS)
1.56 +# undef bad_alloc
1.57 +# undef nothrow_t
1.58 +# undef nothrow
1.59 +# undef _STLP_NULLIFIED_BROKEN_BAD_ALLOC_CLASS
1.60 +# undef _STLP_NULLIFIED_BROKEN_BAD_NOTHROW_T_CLASS
1.61 +# undef _STLP_NULLIFIED_BROKEN_BAD_NOTHROW
1.62 +# endif
1.63 +#else
1.64 +# include <new.h>
1.65 +#endif
1.66 +
1.67 +#if defined (_STLP_NO_BAD_ALLOC) && !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
1.68 +# define _STLP_NEW_DONT_THROW_BAD_ALLOC 1
1.69 +#endif
1.70 +
1.71 +#if defined (_STLP_USE_EXCEPTIONS) && defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
1.72 +
1.73 +# ifndef _STLP_INTERNAL_EXCEPTION
1.74 +# include <stl/_exception.h>
1.75 +# endif
1.76 +
1.77 +_STLP_BEGIN_NAMESPACE
1.78 +
1.79 +# if defined (_STLP_NO_BAD_ALLOC)
1.80 +struct nothrow_t {};
1.81 +# define nothrow nothrow_t()
1.82 +# endif
1.83 +
1.84 +/*
1.85 + * STLport own bad_alloc exception to be used if the native C++ library
1.86 + * do not define it or when the new operator do not throw it to avoid
1.87 + * a useless library dependency.
1.88 + */
1.89 +class bad_alloc : public exception {
1.90 +public:
1.91 + bad_alloc () _STLP_NOTHROW_INHERENTLY { }
1.92 + bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { }
1.93 + bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;}
1.94 + ~bad_alloc () _STLP_NOTHROW_INHERENTLY { }
1.95 + const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; }
1.96 +};
1.97 +
1.98 +_STLP_END_NAMESPACE
1.99 +
1.100 +#endif /* _STLP_USE_EXCEPTIONS && (_STLP_NO_BAD_ALLOC || _STLP_NEW_DONT_THROW_BAD_ALLOC) */
1.101 +
1.102 +#if defined (_STLP_RTTI_BUG)
1.103 +_STLP_BEGIN_NAMESPACE
1.104 +
1.105 +inline void* _STLP_CALL __stl_new(size_t __n)
1.106 +{ return ::malloc(__n); }
1.107 +
1.108 +inline void _STLP_CALL __stl_delete(void* __p)
1.109 +{ ::free(__p); }
1.110 +_STLP_END_NAMESPACE
1.111 +
1.112 +#else /* _STLP_RTTI_BUG */
1.113 +
1.114 +# if defined (_STLP_USE_OWN_NAMESPACE)
1.115 +
1.116 +_STLP_BEGIN_NAMESPACE
1.117 +
1.118 +# if !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
1.119 +using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
1.120 +# endif
1.121 +
1.122 +# if !defined (_STLP_NO_BAD_ALLOC)
1.123 +using _STLP_VENDOR_EXCEPT_STD::nothrow_t;
1.124 +using _STLP_VENDOR_EXCEPT_STD::nothrow;
1.125 +# if defined (_STLP_GLOBAL_NEW_HANDLER)
1.126 +using ::new_handler;
1.127 +using ::set_new_handler;
1.128 +# else
1.129 +using _STLP_VENDOR_EXCEPT_STD::new_handler;
1.130 +using _STLP_VENDOR_EXCEPT_STD::set_new_handler;
1.131 +# endif
1.132 +# endif /* !_STLP_NO_BAD_ALLOC */
1.133 +
1.134 +_STLP_END_NAMESPACE
1.135 +# endif /* _STLP_USE_OWN_NAMESPACE */
1.136 +
1.137 +# if defined (_STLP_USE_EXCEPTIONS) && \
1.138 + (defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW_BAD_ALLOC))
1.139 +# define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x; if (__y == 0) { _STLP_THROW(_STLP_STD::bad_alloc()); } return __y
1.140 +# else
1.141 +# define _STLP_CHECK_NULL_ALLOC(__x) return __x
1.142 +# endif
1.143 +
1.144 +_STLP_BEGIN_NAMESPACE
1.145 +
1.146 +# if ((defined (__IBMCPP__) || defined (__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined (__DEBUG_ALLOC__))
1.147 +inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator _STLP_NEW(__n, __FILE__, __LINE__)); }
1.148 +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
1.149 +# else
1.150 +inline void* _STLP_CALL __stl_new(size_t __n) { _STLP_CHECK_NULL_ALLOC(::operator _STLP_NEW(__n)); }
1.151 +inline void _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); }
1.152 +# endif
1.153 +_STLP_END_NAMESPACE
1.154 +
1.155 +#endif /* _STLP_RTTI_BUG */
1.156 +
1.157 +#endif /* _STLP_INTERNAL_NEW */
1.158 +
1.159 +
1.160 +/*
1.161 + * Local Variables:
1.162 + * mode:C++
1.163 + * End:
1.164 + */