mirror of
https://github.com/AxioDL/tinyxml2.git
synced 2025-05-15 11:51:37 +00:00
Merge branch 'Dmitry-Me-properStrPairAssignment'
This commit is contained in:
commit
18f5d7f133
25
tinyxml2.cpp
25
tinyxml2.cpp
@ -70,6 +70,29 @@ StrPair::~StrPair()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void StrPair::TransferTo( StrPair* other )
|
||||||
|
{
|
||||||
|
if ( this == other ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// This in effect implements the assignment operator by "moving"
|
||||||
|
// ownership (as in auto_ptr).
|
||||||
|
|
||||||
|
TIXMLASSERT( other->_flags == 0 );
|
||||||
|
TIXMLASSERT( other->_start == 0 );
|
||||||
|
TIXMLASSERT( other->_end == 0 );
|
||||||
|
|
||||||
|
other->Reset();
|
||||||
|
|
||||||
|
other->_flags = _flags;
|
||||||
|
other->_start = _start;
|
||||||
|
other->_end = _end;
|
||||||
|
|
||||||
|
_flags = 0;
|
||||||
|
_start = 0;
|
||||||
|
_end = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void StrPair::Reset()
|
void StrPair::Reset()
|
||||||
{
|
{
|
||||||
if ( _flags & NEEDS_DELETE ) {
|
if ( _flags & NEEDS_DELETE ) {
|
||||||
@ -824,7 +847,7 @@ char* XMLNode::ParseDeep( char* p, StrPair* parentEnd )
|
|||||||
// We read the end tag. Return it to the parent.
|
// We read the end tag. Return it to the parent.
|
||||||
if ( ele && ele->ClosingType() == XMLElement::CLOSING ) {
|
if ( ele && ele->ClosingType() == XMLElement::CLOSING ) {
|
||||||
if ( parentEnd ) {
|
if ( parentEnd ) {
|
||||||
*parentEnd = ele->_value;
|
ele->_value.TransferTo( parentEnd );
|
||||||
}
|
}
|
||||||
node->_memPool->SetTracked(); // created and then immediately deleted.
|
node->_memPool->SetTracked(); // created and then immediately deleted.
|
||||||
DeleteNode( node );
|
DeleteNode( node );
|
||||||
|
@ -184,9 +184,9 @@ public:
|
|||||||
char* ParseText( char* in, const char* endTag, int strFlags );
|
char* ParseText( char* in, const char* endTag, int strFlags );
|
||||||
char* ParseName( char* in );
|
char* ParseName( char* in );
|
||||||
|
|
||||||
private:
|
void TransferTo( StrPair* other );
|
||||||
void operator=(const StrPair& rhs);
|
|
||||||
|
|
||||||
|
private:
|
||||||
void Reset();
|
void Reset();
|
||||||
void CollapseWhitespace();
|
void CollapseWhitespace();
|
||||||
|
|
||||||
@ -199,6 +199,9 @@ private:
|
|||||||
int _flags;
|
int _flags;
|
||||||
char* _start;
|
char* _start;
|
||||||
char* _end;
|
char* _end;
|
||||||
|
|
||||||
|
StrPair( const StrPair& other ); // not supported
|
||||||
|
void operator=( StrPair& other ); // not supported, use TransferTo()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -1442,12 +1442,10 @@ int main( int argc, const char ** argv )
|
|||||||
|
|
||||||
#if defined( _MSC_VER ) && defined( DEBUG )
|
#if defined( _MSC_VER ) && defined( DEBUG )
|
||||||
_CrtMemCheckpoint( &endMemState );
|
_CrtMemCheckpoint( &endMemState );
|
||||||
//_CrtMemDumpStatistics( &endMemState );
|
|
||||||
|
|
||||||
_CrtMemState diffMemState;
|
_CrtMemState diffMemState;
|
||||||
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
|
_CrtMemDifference( &diffMemState, &startMemState, &endMemState );
|
||||||
_CrtMemDumpStatistics( &diffMemState );
|
_CrtMemDumpStatistics( &diffMemState );
|
||||||
//printf( "new total=%d\n", gNewTotal );
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
printf ("\nPass %d, Fail %d\n", gPass, gFail);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user