Lots of stuff

Former-commit-id: 39b5f3c01e
This commit is contained in:
2022-10-03 20:00:46 -04:00
parent 469c499a6b
commit bc202ba493
47 changed files with 701 additions and 312 deletions

View File

@@ -8,8 +8,23 @@
namespace rstl {
struct rmemory_allocator {
template < typename T >
static void allocate(T*& out, int sz) {
out = reinterpret_cast< T* >(new u8[sz]);
static void allocate(T*& out, int count) {
int size = count * sizeof(T);
if (size == 0) {
out = nullptr;
} else {
out = reinterpret_cast< T* >(new u8[size]);
}
}
// TODO: this fixes a regswap in vector::reserve
template < typename T >
static T* allocate2(int count) {
int size = count * sizeof(T);
if (size == 0) {
return nullptr;
} else {
return reinterpret_cast< T* >(new u8[size]);
}
}
template < typename T >
static void deallocate(T* ptr) {