/*  Metrowerks Standard Library  Version 4.0  1998 August 10  */

/*  $Date: 1998/12/04 23:58:22 $ 
 *  $Revision: 1.2 $ 
 *  $NoKeywords: $ 
 *
 *		Copyright  1995-1998 Metrowerks, Inc.
 *		All rights reserved.
 */


/*
 *	new        hh 971206  filename used to be new.h
 */
 
#ifndef __new__
#define __new__

#include <mcompile.h>
#include <cstddef>     // MW-mm 960723 // hh 971226 changed from <size_t.h>
#include <exception>		//960902 bkoz

#ifndef RC_INVOKED // hh 971230

#pragma options align=native
#if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
	#pragma import on
#endif

#ifdef MSIPL_USING_NAMESPACE  // MW-mm 960213b
	namespace std {
#endif

#if !defined(_PPC_RUNTIME_COMPAT)
	class bad_alloc : public exception {  // hh 971226 rewrite
	public:
		bad_alloc () MSIPL_THROW {}
		bad_alloc (const bad_alloc&) MSIPL_THROW {}
		bad_alloc& operator= (const bad_alloc&) MSIPL_THROW {return *this;}
		virtual ~bad_alloc () MSIPL_THROW {};
		virtual const char* what () const MSIPL_THROW {return "Allocation Failure";}
	};
#endif /* __be_os */	

	struct nothrow_t {};				//970415 bkoz
	extern nothrow_t nothrow;			//971010 vss
		
	typedef void (*new_handler)(); 
	
//	#if __dest_os == __win32_os      hh is this necessary ???
//		new_handler set_new_handler(new_handler new_p); 
//	#else
		new_handler set_new_handler(new_handler new_p) MSIPL_THROW; 
//	#endif

#ifdef MSIPL_USING_NAMESPACE // MW-mm 960213b
	} // namespace std 
#endif

#ifdef MSIPL_THROW_SPECS
	void* operator new(MSIPLSTD::size_t size) throw(MSIPLSTD::bad_alloc);
#else
	void* operator new(MSIPLSTD::size_t size);
#endif
void* operator new(MSIPLSTD::size_t size, const MSIPLSTD::nothrow_t&) MSIPL_THROW;
inline void* operator new(MSIPLSTD::size_t, void* ptr) MSIPL_THROW {return ptr;}
void  operator delete(void* ptr) MSIPL_THROW;
#if __MWERKS__ >= 0x2020 || defined (__GNUC__)
//	void  operator delete(void* ptr, const MSIPLSTD::nothrow_t&) MSIPL_THROW;
//	inline void  operator delete  (void*, void*) MSIPL_THROW {}
	#ifdef MSIPL_THROW_SPECS
		void* operator new[](MSIPLSTD::size_t size) throw(MSIPLSTD::bad_alloc);
	#else
		void* operator new[](MSIPLSTD::size_t size);
	#endif
	void* operator new[](MSIPLSTD::size_t size, const MSIPLSTD::nothrow_t&) MSIPL_THROW;
	void  operator delete[](void* ptr) MSIPL_THROW;
//	void  operator delete[](void* ptr, const MSIPLSTD::nothrow_t&) MSIPL_THROW;
	inline void* operator new[](MSIPLSTD::size_t, void* ptr) MSIPL_THROW {return ptr;}
//	inline void  operator delete[](void*, void*) MSIPL_THROW {}
#endif

#ifdef MSIPL_USING_NAMESPACE   // hh 971206  put this stuff in std::
	namespace std {
#endif

//	non-standard functions
extern char	__throws_bad_alloc;
extern void __throw_bad_alloc();
extern void _set_newpoolsize(size_t);		//	default: 0x00010000L
extern void _set_newnonptrmax(size_t);		//	default: 0x00001000L
extern char _prealloc_newpool(size_t);		//	preallocte a new buffer

#ifdef MSIPL_USING_NAMESPACE   // hh 971206
	}
#endif

#if defined(__CFM68K__) && !defined(__USING_STATIC_LIBS__)
	#pragma import reset
#endif
#pragma options align=reset

#endif // RC_INVOKED

#endif /*__new__*/

/* Change record
MW-mm 960213a  Deleted the definition of the bad_except class
MW-mm 960213b  Put Modena wrappers around namespace
MW-mm 960213c  Changed declaration to avoid syntax error in line with <new>
MW-mm 960307a  Changed declaration to avoid syntax error in line with delete
MW-mm 960723   Added include of size_t.h so that new.h can be compiled independently
mw-bk 960813   added andreas's changes for new throw bad_alloc()
mw-bk 960902   moved class exception into exception header, including excpt instead of stdexcept
mw-bk 961210 	added alignment wrapper
mw-bk 961221	line 65 added moto wrapper (mmoss)
vss   971006   namespace std
vss   971010   Put in export of nothrow_t as per standards
hh    971206   Added namespace support
//>>>HOMMEL 971204  Added support for operator new[]
// hh 971226 rewrite bad_alloc
// hh 971230   added RC_INVOKED wrapper
// vss  980616  removed DebugNew lines
*/
