Refactor new usage to rs_new

Former-commit-id: cbf7b415ed96fe9ad0a0a9a11cc1ffb18b5c07da
This commit is contained in:
2023-10-12 05:14:12 -07:00
parent 2d4ba7275f
commit cc41943a2a
27 changed files with 58 additions and 60 deletions

View File

@@ -2,6 +2,7 @@
#define _RSTL_RC_PTR
#include "types.h"
#include "rstl/rmemory_allocator.hpp"
namespace rstl {
class CRefData {
@@ -25,7 +26,7 @@ template < typename T >
class rc_ptr {
public:
rc_ptr() : x0_refData(&CRefData::sNull) { x0_refData->AddRef(); }
rc_ptr(const T* ptr) : x0_refData(new CRefData(ptr)) {}
rc_ptr(const T* ptr) : x0_refData(rs_new CRefData(ptr)) {}
rc_ptr(const rc_ptr& other) : x0_refData(other.x0_refData) { x0_refData->AddRef(); }
~rc_ptr() { ReleaseData(); }
T* GetPtr() const { return static_cast< T* >(x0_refData->GetPtr()); }

View File

@@ -15,7 +15,7 @@ struct rmemory_allocator {
if (size == 0) {
out = nullptr;
} else {
out = reinterpret_cast< T* >(NEW uchar[size]);
out = reinterpret_cast< T* >(rs_new uchar[size]);
}
}
// TODO: this fixes a regswap in vector::reserve
@@ -25,7 +25,7 @@ struct rmemory_allocator {
if (size == 0) {
return nullptr;
} else {
return reinterpret_cast< T* >(NEW uchar[size]);
return reinterpret_cast< T* >(rs_new uchar[size]);
}
}
template < typename T >