Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/include/internal/catch_stringref.cpp
diff options
context:
space:
mode:
authorPhil Nash2017-08-14 09:14:49 +0100
committerPhil Nash2017-08-14 09:14:49 +0100
commit94d347b05939385a827499932f7b02ce7ccc9c45 (patch)
treea8a9768e0bb5534c4738906aec8b4fb6332f517a /include/internal/catch_stringref.cpp
parent3772f69f0fbba0620df4c262b1925444a0567b37 (diff)
downloadcatch3-94d347b05939385a827499932f7b02ce7ccc9c45.tar.gz
Removed StringData
Diffstat (limited to 'include/internal/catch_stringref.cpp')
-rw-r--r--include/internal/catch_stringref.cpp18
1 files changed, 7 insertions, 11 deletions
diff --git a/include/internal/catch_stringref.cpp b/include/internal/catch_stringref.cpp
index 61e001bc..a6389bd4 100644
--- a/include/internal/catch_stringref.cpp
+++ b/include/internal/catch_stringref.cpp
@@ -6,7 +6,6 @@
*/
#include "catch_stringref.h"
-#include "catch_stringdata.h"
#include <cstring>
#include <ostream>
@@ -25,12 +24,8 @@ namespace Catch {
StringRef::StringRef( StringRef const& other ) noexcept
: m_start( other.m_start ),
- m_size( other.m_size ),
- m_data( other.m_data )
- {
- if( m_data )
- m_data->addRef();
- }
+ m_size( other.m_size )
+ {}
StringRef::StringRef( StringRef&& other ) noexcept
: m_start( other.m_start ),
@@ -62,8 +57,7 @@ namespace Catch {
{}
StringRef::~StringRef() noexcept {
- if( isOwned() )
- m_data->release();
+ delete[] m_data;
}
auto StringRef::operator = ( StringRef other ) noexcept -> StringRef& {
@@ -98,8 +92,10 @@ namespace Catch {
void StringRef::takeOwnership() {
if( !isOwned() ) {
- m_data = StringData::create( *this );
- m_start = m_data->chars;
+ m_data = new char[m_size+1];
+ strncpy( m_data, m_start, m_size );
+ m_data[m_size] = '\0';
+ m_start = m_data;
}
}
auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef {