home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 May / MICD_2000_05.iso / CBuilder5 / INSTALL / DATA1.CAB / Program_Built_Files / Include / new.h < prev    next >
C/C++ Source or Header  |  2000-02-01  |  6KB  |  167 lines

  1. #ifndef __NEW_H
  2. #define __NEW_H
  3. #pragma option push -b -a8 -pc -Vx- -Ve- -w-inl -w-aus -w-sig
  4. // -*- C++ -*-
  5. #if !defined(_HPACC_)
  6. #ifndef __STD_NEW
  7. #define __STD_NEW
  8.  
  9. /***************************************************************************
  10.  *
  11.  * new - declarations for the Standard Library new header
  12.  *
  13.  ***************************************************************************
  14.  *
  15.  * Copyright (c) 1994-1999 Rogue Wave Software, Inc.  All Rights Reserved.
  16.  *
  17.  * This computer software is owned by Rogue Wave Software, Inc. and is
  18.  * protected by U.S. copyright laws and other laws and by international
  19.  * treaties.  This computer software is furnished by Rogue Wave Software,
  20.  * Inc. pursuant to a written license agreement and may be used, copied,
  21.  * transmitted, and stored only in accordance with the terms of such
  22.  * license and with the inclusion of the above copyright notice.  This
  23.  * computer software or any other copies thereof may not be provided or
  24.  * otherwise made available to any other person.
  25.  *
  26.  * U.S. Government Restricted Rights.  This computer software is provided
  27.  * with Restricted Rights.  Use, duplication, or disclosure by the
  28.  * Government is subject to restrictions as set forth in subparagraph (c)
  29.  * (1) (ii) of The Rights in Technical Data and Computer Software clause
  30.  * at DFARS 252.227-7013 or subparagraphs (c) (1) and (2) of the
  31.  * Commercial Computer Software û Restricted Rights at 48 CFR 52.227-19,
  32.  * as applicable.  Manufacturer is Rogue Wave Software, Inc., 5500
  33.  * Flatiron Parkway, Boulder, Colorado 80301 USA.
  34.  *
  35.  **************************************************************************/
  36.  
  37. #include <stdcomp.h>
  38. #include <rw/stddefs.h> 
  39. #include <exception>
  40. #include <alloc.h>  // __BORLANDC__ needed for malloc
  41.  
  42. #ifndef _RWSTD_NO_NAMESPACE 
  43. namespace __rwstd {
  44. #endif
  45.  
  46. extern const char _RWSTDExportFunc(*) __rw_stdexcept_BadAllocException;
  47.  
  48. #ifndef _RWSTD_NO_NAMESPACE
  49. }
  50. namespace std {
  51. #endif
  52.  
  53. #if !defined(_RWSTD_BAD_ALLOC_DEFINED) || defined(__TURBOC__)
  54. class _RWSTDExport bad_alloc : public exception     
  55.   public:
  56.     bad_alloc () _RWSTD_THROW_SPEC_NULL : exception( )
  57.     { ; }
  58.     bad_alloc(const bad_alloc&) _RWSTD_THROW_SPEC_NULL
  59.     { ; }
  60.     bad_alloc& operator=(const bad_alloc&) _RWSTD_THROW_SPEC_NULL
  61.     { return *this; }
  62.     virtual ~bad_alloc ()  _RWSTD_THROW_SPEC_NULL;
  63.  
  64.     virtual const char * what () const  _RWSTD_THROW_SPEC_NULL
  65.     { 
  66.       return __RWSTD::__rw_stdexcept_BadAllocException;
  67.     }
  68. };
  69. #else
  70. #ifndef _RWSTD_NO_NAMESPACE 
  71. }
  72. #endif
  73. #if defined(_MSC_VER) && !defined(__BORLANDC__)
  74. #include _RWSTD_MS42_HEADER(new)
  75. #else
  76. #include <new.h>
  77. #endif
  78. #ifndef _RWSTD_NO_NAMESPACE 
  79. namespace std {
  80. #endif
  81. #endif /*_RWSTD_BAD_ALLOC_DEFINED */
  82.  
  83. #ifndef _RWSTD_NOTHROW_IN_STD
  84. struct nothrow_t {};
  85. extern nothrow_t nothrow;
  86. #endif // _RWSTD_NOTHROW_IN_STD
  87.  
  88. #if !defined(_RWSTD_EXCEPTION_HANDLER_IN_STD) || defined(__BORLANDC__)
  89. typedef void ( _RTLENTRY *new_handler) ();
  90.  
  91. #if !defined(_MSC_VER) || defined(__BORLANDC__)
  92. extern new_handler _RTLENTRY _EXPFUNC set_new_handler( new_handler new_p );
  93. #endif
  94. #endif // ! _RWSTD_EXCEPTION_HANDLER_IN_STD || __BORLANDC__
  95. #ifndef _RWSTD_NO_NAMESPACE
  96. }
  97. #endif
  98.  
  99. #ifndef _RWSTD_NO_NEW_BRACKETS
  100. #ifndef _RWSTD_NO_THROW_SPEC_ON_NEW
  101. inline void * _RTLENTRY operator new(size_t, void* ptr)  _RWSTD_THROW_SPEC_NULL
  102.  { return ptr; }
  103. #if !defined(__sgi) || (defined(__sgi) && defined(_COMPILER_VERSION) && (_COMPILER_VERSION < 0x2D1))
  104. inline void*  _RTLENTRY operator new[] ( size_t, void* ptr)  _RWSTD_THROW_SPEC_NULL
  105.  { return ptr; }
  106. #endif
  107. #else
  108. inline void * _RTLENTRY _EXPFUNC operator new(size_t, void*)
  109.  { return ptr; }
  110. #if !defined(__sgi) || (defined(__sgi) && defined(_COMPILER_VERSION) && (_COMPILER_VERSION < 0x2D1))
  111. inline void*  _RTLENTRY operator new[] ( size_t, void* ptr)
  112.  { return ptr; }
  113. #endif
  114. #endif // _RWSTD_NO_THROW_SPEC_ON_NEW
  115. #else
  116. #if defined(_MSC_VER) && !defined(__BORLANDC__)
  117. #include <new.h>
  118. extern void * _RTLENTRY _EXPFUNC operator new(size_t, void* ptr);
  119. #else
  120. #ifndef _RWSTD_NO_THROW_SPEC_ON_NEW
  121. static inline  void * _RTLENTRY operator new(size_t, void* ptr) _RWSTD_THROW_SPEC_NULL
  122.  { return ptr; }
  123. #else
  124. static inline  void * _RTLENTRY operator new(size_t, void* ptr)
  125.  { return ptr; }
  126. #endif // _RWSTD_NO_THROW_SPEC_ON_NEW
  127. #endif // _MSC_VER
  128. #endif // _RWSTD_NO_NEW_BRACKETS
  129.  
  130. #ifdef __BORLANDC__
  131. // Prototypes for the standard global new & delete operators
  132. void * _RTLENTRY _EXPFUNC operator new (size_t);
  133. void   _RTLENTRY _EXPFUNC operator delete (void *);
  134.  
  135. // inline versions of the nothrow_t versions of new & delete operators
  136. inline void * _RTLENTRY operator new (size_t size, const std::nothrow_t &)
  137. {
  138.     size = size ? size : 1;
  139.     return malloc(size);
  140. }
  141. inline void * _RTLENTRY operator new[] (size_t size, const std::nothrow_t &nt)
  142. {
  143.     return ::operator new (size, nt);
  144. }
  145. inline void _RTLENTRY operator delete (void *v, const std::nothrow_t &nt)
  146. {
  147.     ::operator delete (v);  // The standard operator doesn't throw any exceptions
  148. }
  149. inline void _RTLENTRY operator delete[] (void *v, const std::nothrow_t &nt)
  150. {
  151.     ::operator delete[] (v);  // The standard operator doesn't throw any exceptions
  152. }
  153. #endif // __BORLANDC__
  154. #endif /*__STD_NEW */
  155.  
  156. #else
  157. #include <new.h>
  158. #endif /* !defined (_HPACC_) */
  159.  
  160. #ifndef __USING_STD_NAMES__
  161.   using namespace std;
  162. #endif
  163.  
  164. #pragma option pop
  165. #endif /* __NEW_H */
  166.