//  new : headerfile for the free standard C++ library
//  
//  Copyright (C) 1999 by the free standard C++ Library Team
//                        see AUTHORS for more details
//
//  Homepage : http://www.inf.fu-berlin.de/~mkrueger/fscl/
//
//  This library is free software; you can redistribute it and/or
//  modify it under the terms of the GNU Library General Public
//  License as published by the Free Software Foundation; either	
//  version 2 of the License, or (at your option) any later version.
//
//  This library is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
//  Library General Public License for more details.
//  You should have received a copy of the GNU Library General Public
//  License along with this library; if not, write to the Free
//  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//  version : 0.1 last modified : 17.09.99

#ifndef __CPP_NEW
#define __CPP_NEW

#include<cstddef>
#include<cstdio>
#include<cstdlib>
//#include<gc.h>              // GARBAGE COLLECTOR
#include<exception>

namespace std {
	class bad_alloc : public exception
	{
		public:
			bad_alloc() throw()
			{
			}		
			bad_alloc(const bad_alloc &ba) throw()
			{
			}
			bad_alloc &operator=(const bad_alloc &ba) throw()
			{
				return *this;
			}
			virtual ~bad_alloc() throw()
			{
			}		
			virtual const char* what() const throw()
			{
				static const char *s = "bad alloc";
				return s;
			}
	};

	struct nothrow_t 
	{
	};
	
	extern const nothrow_t nothrow;
	typedef void (*new_handler)();
	
	new_handler set_new_handler(new_handler new_p) throw();	
}

void *operator new(std::size_t size) throw(std::bad_alloc);
void *operator new(std::size_t size, const std::nothrow_t& t) throw();
void  operator delete(void* ptr) throw();
void  operator delete(void* ptr, const std::nothrow_t& t) throw();
void *operator new[](std::size_t size) throw(std::bad_alloc);
void *operator new[](std::size_t size, const std::nothrow_t& t) throw();
void  operator delete[](void* ptr) throw();
void  operator delete[](void* ptr, const std::nothrow_t& t) throw();
void *operator new(std::size_t size, void* ptr) throw();
void *operator new[](std::size_t size, void* ptr) throw();
void  operator delete(void* ptr, void* p2) throw();
void  operator delete[](void* ptr, void* p2) throw();


/* 
inline void *operator new(std::size_t size) throw(std::bad_alloc)
{
	return GC_MALLOC(size);
}	

inline void *operator new(std::size_t size, const std::nothrow_t& t) throw()
{
	printf("unchecked\n");
	return GC_MALLOC(size);
}	

inline void  operator delete(void* ptr) throw()
{
	GC_FREE(ptr);
}

inline void  operator delete(void* ptr, const std::nothrow_t& t) throw()
{
	printf("unchecked\n");
	GC_FREE(ptr);
}

inline void *operator new[](std::size_t size) throw(std::bad_alloc)
{
	return GC_MALLOC(size);
}

inline void *operator new[](std::size_t size, const std::nothrow_t& t) throw()
{
	printf("unchecked\n");
	return GC_MALLOC(size);
}

inline void  operator delete[](void* ptr) throw()
{
	GC_FREE(ptr);
}

inline void  operator delete[](void* ptr, const std::nothrow_t& t) throw()
{
	printf("unchecked\n");
	GC_FREE(ptr);
}

inline void *operator new(std::size_t size, void* ptr) throw()
{
	return ptr = GC_MALLOC(size);
}

inline void *operator new[](std::size_t size, void* ptr) throw()
{
	return ptr = GC_MALLOC(size);
}

inline void  operator delete(void* ptr, void* p2) throw()
{
	GC_FREE(ptr);
}

inline void  operator delete[](void* ptr, void* p2) throw()
{
	GC_FREE(ptr);
}
*/
#endif
