Also added a pretty much untested and totally incomplete STL string type.

This commit is contained in:
2024-01-12 01:31:43 +01:00
parent ff3214fa5a
commit 219a48c616
21 changed files with 138 additions and 12 deletions

17
bastl/src/exception.cpp Normal file
View File

@@ -0,0 +1,17 @@
#include <exception>
namespace std
{
const char* exception::what() const noexcept
{
return "";
}
}
#if !defined(__cpp_exceptions)
namespace ba::impl
{
ExceptionAbortHelper gAbortHelper;
}
#endif

50
bastl/src/new.cpp Normal file
View File

@@ -0,0 +1,50 @@
#include <new>
#include <cstdlib>
namespace std
{
const char* bad_alloc::what() const noexcept
{
return "bad_alloc";
}
}
void* operator new(size_t count)
{
if (void* ptr = malloc(count); ptr != nullptr)
{
return ptr;
}
__ba_throw std::bad_alloc();
}
void operator delete(void* data) noexcept
{
std::free(data);
}
void* operator new[](size_t count)
{
if (void* ptr = malloc(count); ptr != nullptr)
{
return ptr;
}
__ba_throw std::bad_alloc();
}
void operator delete[](void* data) noexcept
{
std::free(data);
}
void operator delete(void* data, size_t /* size */) noexcept
{
std::free(data);
}
void operator delete[](void* data, size_t /* size */) noexcept
{
std::free(data);
}