Skip to content

Commit 3fa0876

Browse files
author
Nicholas Reed
committed
free attributes list; SCL git c77471a
1 parent d59bd52 commit 3fa0876

File tree

4 files changed

+23
-10
lines changed

4 files changed

+23
-10
lines changed

src/clstepcore/STEPattribute.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ class SCL_CORE_EXPORT STEPattribute {
9191

9292
public:
9393
const AttrDescriptor * aDesc;
94+
int refCount;
9495

9596
// You know which of these to use based on the return value of
9697
// NonRefType() - see below. BASE_TYPE is defined in baseType.h

src/clstepcore/STEPattribute.inline.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,69 +18,69 @@
1818

1919
/// This is needed so that STEPattribute's can be passed as references to inline functions
2020
STEPattribute::STEPattribute( const STEPattribute & a )
21-
: aDesc( a.aDesc ), _derive( 0 ), _redefAttr( 0 ) {}
21+
: _derive( 0 ), _redefAttr( 0 ), aDesc( a.aDesc ), refCount( 0 ) {}
2222

2323
/// INTEGER
2424
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Integer *p )
25-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
25+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
2626
ptr.i = p;
2727
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
2828
}
2929

3030
/// BINARY
3131
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Binary *p )
32-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
32+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
3333
ptr.b = p;
3434
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
3535
}
3636

3737
/// STRING
3838
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_String *p )
39-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
39+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
4040
ptr.S = p;
4141
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
4242
}
4343

4444
/// REAL & NUMBER
4545
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Real *p )
46-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
46+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
4747
ptr.r = p;
4848
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
4949
}
5050

5151
/// ENTITY
5252
STEPattribute::STEPattribute( const class AttrDescriptor & d,
5353
SDAI_Application_instance * *p )
54-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
54+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
5555
ptr.c = p;
5656
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
5757
}
5858

5959
/// AGGREGATE
6060
STEPattribute::STEPattribute( const class AttrDescriptor & d, STEPaggregate * p )
61-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
61+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
6262
ptr.a = p;
6363
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
6464
}
6565

6666
/// ENUMERATION and Logical
6767
STEPattribute::STEPattribute( const class AttrDescriptor & d, SDAI_Enum *p )
68-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
68+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
6969
ptr.e = p;
7070
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
7171
}
7272

7373
/// SELECT
7474
STEPattribute::STEPattribute( const class AttrDescriptor & d,
7575
class SDAI_Select *p )
76-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
76+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
7777
ptr.sh = p;
7878
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
7979
}
8080

8181
/// UNDEFINED
8282
STEPattribute::STEPattribute( const class AttrDescriptor & d, SCLundefined * p )
83-
: aDesc( &d ), _derive( 0 ), _redefAttr( 0 ) {
83+
: _derive( 0 ), _redefAttr( 0 ), aDesc( &d ), refCount( 0 ) {
8484
ptr.u = p;
8585
assert( &d ); //ensure that the AttrDescriptor is not a null pointer
8686
}

src/clstepcore/STEPattributeList.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ void STEPattributeList::push( STEPattribute * a ) {
7070
}
7171

7272
if( push ) {
73+
a->refCount ++;
7374
AttrListNode * saln = new AttrListNode( a );
7475
AppendNode( saln );
7576
}

src/clstepcore/sdaiApplication_instance.cc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,18 @@ SDAI_Application_instance::SDAI_Application_instance( int fileid, int complex )
4040
}
4141

4242
SDAI_Application_instance::~SDAI_Application_instance() {
43+
STEPattribute *attr;
44+
4345
ResetAttributes();
46+
do {
47+
attr = NextAttribute();
48+
if (attr) {
49+
attr->refCount --;
50+
if (attr->refCount <= 0)
51+
delete attr;
52+
}
53+
} while (attr);
54+
4455

4556
if( MultipleInheritance() ) {
4657
delete nextMiEntity;

0 commit comments

Comments
 (0)