openddl-parser: latest greatest with fixes for invalid reference information.

Signed-off-by: Kim Kulling <kim.kulling@googlemail.com>
pull/502/head
Kim Kulling 2015-03-17 14:25:15 +01:00
parent 7d7ccfd630
commit 0d5a2ce4c1
3 changed files with 23 additions and 6 deletions

View File

@ -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 ) DDLNode::DDLNode( const std::string &type, const std::string &name, size_t idx, DDLNode *parent )
: m_type( type ) : m_type( type )
, m_name( name ) , m_name( name )
@ -51,9 +63,9 @@ DDLNode::DDLNode( const std::string &type, const std::string &name, size_t idx,
, m_children() , m_children()
, m_properties( ddl_nullptr ) , m_properties( ddl_nullptr )
, m_value( ddl_nullptr ) , m_value( ddl_nullptr )
, m_idx( idx )
, m_dtArrayList( ddl_nullptr ) , m_dtArrayList( ddl_nullptr )
, m_references( ddl_nullptr ) { , m_references( ddl_nullptr )
, m_idx( idx ) {
if( m_parent ) { if( m_parent ) {
m_parent->m_children.push_back( this ); 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() { DDLNode::~DDLNode() {
releaseDataType<Property>( m_properties ); releaseDataType<Property>( m_properties );
releaseDataType<Value>( m_value ); releaseDataType<Value>( m_value );
releaseReferencedNames( m_references );
delete m_dtArrayList; delete m_dtArrayList;
m_dtArrayList = ddl_nullptr; m_dtArrayList = ddl_nullptr;

View File

@ -96,8 +96,12 @@ struct Reference {
Reference( size_t numrefs, Name **names ) Reference( size_t numrefs, Name **names )
: m_numRefs( numrefs ) : m_numRefs( numrefs )
, m_referencedName( names ) { , m_referencedName( ddl_nullptr ) {
// empty 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; size_t m_len;
char *m_buffer; char *m_buffer;
Identifier( size_t len, char *buffer ) Identifier( size_t len, char buffer[] )
: m_len( len ) : m_len( len )
, m_buffer( buffer ) { , m_buffer( buffer ) {
// empty // empty

View File

@ -173,7 +173,7 @@ bool isFloat( T *in, T *end ) {
template<class T> template<class T>
inline inline
bool isCharacter( const T in ) { bool isCharacter( const T in ) {
return ( in >= 'a' && in <= 'z' || in >= 'A' && in <= 'Z' ); return ( ( in >= 'a' && in <= 'z' ) || ( in >= 'A' && in <= 'Z' ) );
} }
template<class T> template<class T>