
#include <new>
#include <cstddef>
#include <cstdlib>


namespace std
{

	bad_alloc::~bad_alloc() throw() {}

	const nothrow_t nothrow = {};

} /* namespace std */


void *	operator new(std::size_t size) throw(std::bad_alloc)
{
	if (size == 0) size = 1;
	void * ptr = std::malloc(size);
#ifdef __EXCEPTIONS
	if (!ptr) throw std::bad_alloc();
#else
	if (!ptr) std::abort();
#endif
	return ptr;
}


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

void	operator delete(void * ptr) throw()
{
	if (ptr) std::free(ptr);
}


void	operator delete[](void * ptr) throw()
{
	::operator delete(ptr);
}


void *	operator new(std::size_t size, const std::nothrow_t &) throw()
{
	if (size == 0) size = 1;
	return std::malloc(size);
}


void *	operator new[](std::size_t size, const std::nothrow_t & nothrow) throw()
{
	return ::operator new(size, nothrow);
}


void	operator delete(void * ptr, const std::nothrow_t &) throw()
{
	::operator delete(ptr);
}


void	operator delete[](void * ptr, const std::nothrow_t &) throw()
{
	::operator delete(ptr);
}
