From 707400b4c6de94a22075b17d8d4ef08fa75813d9 Mon Sep 17 00:00:00 2001 From: Baptiste Lepilleur Date: Fri, 19 Nov 2004 19:00:44 +0000 Subject: added specific copy constructor implementatin to ensure string buffer are detached during copy (therefore providing thread-safe copy constructor for non thread-safe std::string copy constructor implementation). --- src/cppunit/SourceLine.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/cppunit/SourceLine.cpp') diff --git a/src/cppunit/SourceLine.cpp b/src/cppunit/SourceLine.cpp index bd70709..dfadae3 100644 --- a/src/cppunit/SourceLine.cpp +++ b/src/cppunit/SourceLine.cpp @@ -10,11 +10,30 @@ SourceLine::SourceLine() : } +SourceLine::SourceLine( const SourceLine &other ) + : m_fileName( other.m_fileName.c_str() ) + , m_lineNumber( other.m_lineNumber ) +{ +} + + SourceLine::SourceLine( const std::string &fileName, - int lineNumber ) : - m_fileName( fileName ), - m_lineNumber( lineNumber ) + int lineNumber ) + : m_fileName( fileName.c_str() ) + , m_lineNumber( lineNumber ) +{ +} + + +SourceLine & +SourceLine::operator =( const SourceLine &other ) { + if ( this != &other ) + { + m_fileName = other.m_fileName.c_str(); + m_lineNumber = other.m_lineNumber; + } + return *this; } -- cgit v1.2.1