Core/String: Replace manual memory management/COW by smart pointers
Former-commit-id: 27cab7f0642619ab47d53ed59c737992534f2979
This commit is contained in:
@@ -4,6 +4,31 @@
|
||||
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
inline NzString::NzString(std::shared_ptr<SharedString>&& sharedString) :
|
||||
m_sharedString(std::move(sharedString))
|
||||
{
|
||||
}
|
||||
|
||||
inline void NzString::ReleaseString()
|
||||
{
|
||||
m_sharedString = std::move(GetEmptyString());
|
||||
}
|
||||
|
||||
inline NzString::SharedString::SharedString() : // Special case: empty string
|
||||
capacity(0),
|
||||
size(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline NzString::SharedString::SharedString(unsigned int strSize) :
|
||||
capacity(strSize),
|
||||
size(strSize),
|
||||
string(new char[strSize + 1])
|
||||
{
|
||||
string[strSize] = '\0';
|
||||
}
|
||||
|
||||
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
|
||||
Reference in New Issue
Block a user