ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

_new.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 1999
00003  * Boris Fomitchev
00004  *
00005  * This material is provided "as is", with absolutely no warranty expressed
00006  * or implied. Any use is at your own risk.
00007  *
00008  * Permission to use or copy this software for any purpose is hereby granted
00009  * without fee, provided the above notices are retained on all copies.
00010  * Permission to modify the code and to distribute modified code is granted,
00011  * provided the above notices are retained, and a notice that the code was
00012  * modified is included with the above copyright notice.
00013  *
00014  */
00015 
00016 #ifndef _STLP_INTERNAL_NEW
00017 #define _STLP_INTERNAL_NEW
00018 
00019 #ifndef _STLP_INTERNAL_CSTDDEF
00020 // size_t
00021 #  include <stl/_cstddef.h>
00022 #endif
00023 
00024 #if defined (__BORLANDC__) && (__BORLANDC__ < 0x570)
00025 // new.h uses ::malloc ;(
00026 #  include _STLP_NATIVE_CPP_C_HEADER(cstdlib)
00027 using _STLP_VENDOR_CSTD::malloc;
00028 #endif
00029 
00030 #if !defined (_STLP_NO_NEW_NEW_HEADER)
00031 // eMbedded Visual C++ .NET unfortunately uses _INC_NEW for both <new.h> and <new>
00032 // we undefine the symbol to get the stuff in the SDK's <new>
00033 #  if defined (_STLP_WCE_NET) && defined (_INC_NEW)
00034 #    undef _INC_NEW
00035 #  endif
00036 
00037 #  if defined (new)
00038 /* STLport cannot replace native Std library new header if new is a macro,
00039  * please define new macro after <new> header inclusion.
00040  */
00041 #    error Cannot include native new header as new is a macro.
00042 #  endif
00043 
00044 #  if defined (_STLP_HAS_INCLUDE_NEXT)
00045 #    include_next <new>
00046 #  else
00047 #    include _STLP_NATIVE_CPP_RUNTIME_HEADER(new)
00048 #  endif
00049 #else
00050 #  include <new.h>
00051 #endif
00052 
00053 #if defined (_STLP_NO_BAD_ALLOC) && !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
00054 #  define _STLP_NEW_DONT_THROW_BAD_ALLOC 1
00055 #endif
00056 
00057 #if defined (_STLP_USE_EXCEPTIONS) && defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
00058 
00059 #  ifndef _STLP_INTERNAL_EXCEPTION
00060 #    include <stl/_exception.h>
00061 #  endif
00062 
00063 _STLP_BEGIN_NAMESPACE
00064 
00065 #  if defined (_STLP_NO_BAD_ALLOC)
00066 struct nothrow_t {};
00067 #    define nothrow nothrow_t()
00068 #  endif
00069 
00070 /*
00071  * STLport own bad_alloc exception to be used if the native C++ library
00072  * do not define it or when the new operator do not throw it to avoid
00073  * a useless library dependency.
00074  */
00075 class bad_alloc : public exception {
00076 public:
00077   bad_alloc () _STLP_NOTHROW_INHERENTLY { }
00078   bad_alloc(const bad_alloc&) _STLP_NOTHROW_INHERENTLY { }
00079   bad_alloc& operator=(const bad_alloc&) _STLP_NOTHROW_INHERENTLY {return *this;}
00080   ~bad_alloc () _STLP_NOTHROW_INHERENTLY { }
00081   const char* what() const _STLP_NOTHROW_INHERENTLY { return "bad alloc"; }
00082 };
00083 
00084 _STLP_END_NAMESPACE
00085 
00086 #endif /* _STLP_USE_EXCEPTIONS && (_STLP_NO_BAD_ALLOC || _STLP_NEW_DONT_THROW_BAD_ALLOC) */
00087 
00088 #if defined (_STLP_USE_OWN_NAMESPACE)
00089 
00090 _STLP_BEGIN_NAMESPACE
00091 
00092 #  if !defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
00093 using _STLP_VENDOR_EXCEPT_STD::bad_alloc;
00094 #  endif
00095 
00096 #  if !defined (_STLP_NO_BAD_ALLOC)
00097 using _STLP_VENDOR_EXCEPT_STD::nothrow_t;
00098 using _STLP_VENDOR_EXCEPT_STD::nothrow;
00099 #    if defined (_STLP_GLOBAL_NEW_HANDLER)
00100 using ::new_handler;
00101 using ::set_new_handler;
00102 #    else
00103 using _STLP_VENDOR_EXCEPT_STD::new_handler;
00104 using _STLP_VENDOR_EXCEPT_STD::set_new_handler;
00105 #    endif
00106 #  endif /* !_STLP_NO_BAD_ALLOC */
00107 
00108 _STLP_END_NAMESPACE
00109 #endif /* _STLP_USE_OWN_NAMESPACE */
00110 
00111 #ifndef _STLP_THROW_BAD_ALLOC
00112 #  if !defined (_STLP_USE_EXCEPTIONS)
00113 #    ifndef _STLP_INTERNAL_CSTDIO
00114 #      include <stl/_cstdio.h>
00115 #    endif
00116 #    define _STLP_THROW_BAD_ALLOC puts("out of memory\n"); exit(1)
00117 #  else
00118 #    define _STLP_THROW_BAD_ALLOC _STLP_THROW(_STLP_STD::bad_alloc())
00119 #  endif
00120 #endif
00121 
00122 #if defined (_STLP_NO_NEW_NEW_HEADER) || defined (_STLP_NEW_DONT_THROW_BAD_ALLOC)
00123 #  define _STLP_CHECK_NULL_ALLOC(__x) void* __y = __x; if (__y == 0) { _STLP_THROW_BAD_ALLOC; } return __y
00124 #else
00125 #  define _STLP_CHECK_NULL_ALLOC(__x) return __x
00126 #endif
00127 
00128 _STLP_BEGIN_NAMESPACE
00129 
00130 #if ((defined (__IBMCPP__) || defined (__OS400__) || defined (__xlC__) || defined (qTidyHeap)) && defined (_STLP_DEBUG_ALLOC))
00131 inline void* _STLP_CALL __stl_new(size_t __n)   { _STLP_CHECK_NULL_ALLOC(::operator new(__n, __FILE__, __LINE__)); }
00132 inline void  _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p, __FILE__, __LINE__); }
00133 #else
00134 inline void* _STLP_CALL __stl_new(size_t __n)   { _STLP_CHECK_NULL_ALLOC(::operator new(__n)); }
00135 inline void  _STLP_CALL __stl_delete(void* __p) { ::operator delete(__p); }
00136 #endif
00137 _STLP_END_NAMESPACE
00138 
00139 #endif /* _STLP_INTERNAL_NEW */
00140 
00141 /*
00142  * Local Variables:
00143  * mode:C++
00144  * End:
00145  */

Generated on Sat May 26 2012 04:27:53 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.