Skip to content

Commit 8a2665e

Browse files
committed
Fixed memory leaks for STEPaggregate data.
* Data was created for use with STEPaggregate types in fedex_plus generated code but never destroyed. * Fixed some code style alignment. * STEPaggregate's STEPnodes never got destroyed.
1 parent 4740f4d commit 8a2665e

3 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/clstepcore/STEPaggregate.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ STEPaggregate::STEPaggregate() {
4040
}
4141

4242
STEPaggregate::~STEPaggregate() {
43+
STEPnode *node;
44+
45+
node = (STEPnode*) head;
46+
while ( node ) {
47+
head = node->NextNode();
48+
delete node;
49+
node = (STEPnode*) head;
50+
}
4351
}
4452

4553
STEPaggregate & STEPaggregate::ShallowCopy( const STEPaggregate & a ) {
@@ -829,6 +837,7 @@ SelectNode::SelectNode() {
829837
}
830838

831839
SelectNode::~SelectNode() {
840+
delete node;
832841
}
833842

834843
SingleLinkNode * SelectNode::NewNode() {

src/clstepcore/STEPattribute.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ class SCL_CORE_EXPORT STEPattribute {
105105
SDAI_Binary * b; // BINARY_TYPE
106106
SDAI_Real * r; // REAL_TYPE and NUMBER_TYPE (Real is a double)
107107
SDAI_Application_instance * * c; // ENTITY_TYPE
108-
STEPaggregate * a; // AGGREGATE_TYPE
108+
STEPaggregate * a; // AGGREGATE_TYPE
109109
SDAI_Enum * e; // ENUM_TYPE, BOOLEAN_TYPE, and LOGICAL_TYPE
110110
SDAI_Select * sh; // SELECT_TYPE
111-
SCLundefined * u; // UNKNOWN_TYPE
111+
SCLundefined * u; // UNKNOWN_TYPE
112112
void * p;
113113

114114
} ptr;

src/fedex_plus/classes.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,24 @@ void LIBstructor_print( Entity entity, FILE * file, Schema schema ) {
16611661
to be deleted -- attributes will need reference count */
16621662

16631663
entnm = ENTITYget_classname( entity );
1664-
fprintf( file, "%s::~%s () { }\n", entnm, entnm );
1664+
fprintf( file, "%s::~%s () {\n", entnm, entnm );
1665+
1666+
attr_list = ENTITYget_attributes( entity );
1667+
1668+
LISTdo( attr_list, a, Variable )
1669+
if( VARget_initializer( a ) == EXPRESSION_NULL ) {
1670+
generate_attribute_name( a, attrnm );
1671+
t = VARget_type( a );
1672+
1673+
if( ( ! VARget_inverse( a ) ) && ( ! VARis_derived( a ) ) ) {
1674+
if( TYPEis_aggregate( t ) ) {
1675+
fprintf( file, " delete _%s;\n", attrnm );
1676+
}
1677+
}
1678+
}
1679+
LISTod;
1680+
1681+
fprintf( file, "}\n" );
16651682
}
16661683

16671684
/********************/

0 commit comments

Comments
 (0)