diff --git a/contrib/openddlparser/code/DDLNode.cpp b/contrib/openddlparser/code/DDLNode.cpp index e65f1c45e..24f0da9d1 100644 --- a/contrib/openddlparser/code/DDLNode.cpp +++ b/contrib/openddlparser/code/DDLNode.cpp @@ -44,6 +44,18 @@ static void releaseDataType( T *ptr ) { } } +static void releaseReferencedNames( Reference *ref ) { + if( ddl_nullptr == ref ) { + return; + } + + if( ref->m_referencedName ) { + for( size_t i = 0; i < ref->m_numRefs; i++ ) { + delete ref->m_referencedName; + } + } +} + DDLNode::DDLNode( const std::string &type, const std::string &name, size_t idx, DDLNode *parent ) : m_type( type ) , m_name( name ) @@ -51,9 +63,9 @@ DDLNode::DDLNode( const std::string &type, const std::string &name, size_t idx, , m_children() , m_properties( ddl_nullptr ) , m_value( ddl_nullptr ) -, m_idx( idx ) , m_dtArrayList( ddl_nullptr ) -, m_references( ddl_nullptr ) { +, m_references( ddl_nullptr ) +, m_idx( idx ) { if( m_parent ) { m_parent->m_children.push_back( this ); } @@ -62,6 +74,7 @@ DDLNode::DDLNode( const std::string &type, const std::string &name, size_t idx, DDLNode::~DDLNode() { releaseDataType( m_properties ); releaseDataType( m_value ); + releaseReferencedNames( m_references ); delete m_dtArrayList; m_dtArrayList = ddl_nullptr; diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h b/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h index 4a1ff2749..ff182432d 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLCommon.h @@ -96,8 +96,12 @@ struct Reference { Reference( size_t numrefs, Name **names ) : m_numRefs( numrefs ) - , m_referencedName( names ) { - // empty + , m_referencedName( ddl_nullptr ) { + m_referencedName = new Name *[ numrefs ]; + for( size_t i = 0; i < numrefs; i++ ) { + Name *name = new Name( names[ i ]->m_type, names[ i ]->m_id ); + m_referencedName[ i ] = name; + } } }; @@ -105,7 +109,7 @@ struct Identifier { size_t m_len; char *m_buffer; - Identifier( size_t len, char *buffer ) + Identifier( size_t len, char buffer[] ) : m_len( len ) , m_buffer( buffer ) { // empty diff --git a/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h b/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h index eb900309c..a8d21b710 100644 --- a/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h +++ b/contrib/openddlparser/include/openddlparser/OpenDDLParserUtils.h @@ -173,7 +173,7 @@ bool isFloat( T *in, T *end ) { template inline bool isCharacter( const T in ) { - return ( in >= 'a' && in <= 'z' || in >= 'A' && in <= 'Z' ); + return ( ( in >= 'a' && in <= 'z' ) || ( in >= 'A' && in <= 'Z' ) ); } template