bionic/libstdc++/src/new.cpp

58 lines
783 B
C++
Raw Normal View History

2008-10-21 16:00:00 +02:00
#include "new"
#include <stdlib.h>
const std::nothrow_t std::nothrow = {};
void* operator new(std::size_t size)
{
void* p = malloc(size);
if (p == NULL) {
abort();
2008-10-21 16:00:00 +02:00
}
return p;
}
void* operator new[](std::size_t size)
{
void* p = malloc(size);
if (p == NULL) {
abort();
2008-10-21 16:00:00 +02:00
}
return p;
}
void operator delete(void* ptr)
{
free(ptr);
2008-10-21 16:00:00 +02:00
}
void operator delete[](void* ptr)
{
free(ptr);
2008-10-21 16:00:00 +02:00
}
void* operator new(std::size_t size, const std::nothrow_t&)
{
return malloc(size);
}
void* operator new[](std::size_t size, const std::nothrow_t&)
{
return malloc(size);
}
void operator delete(void* ptr, const std::nothrow_t&)
{
free(ptr);
2008-10-21 16:00:00 +02:00
}
void operator delete[](void* ptr, const std::nothrow_t&)
{
free(ptr);
2008-10-21 16:00:00 +02:00
}