Skip to content

Commit c7bd9fa

Browse files
starseekercshorler
authored andcommitted
Use array deletes, clean up temporary objects.
1 parent 4446d02 commit c7bd9fa

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/cldai/sdaiEntity_extent_set.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ SDAI_Entity_extent__set::SDAI_Entity_extent__set( int defaultSize ) {
5151
}
5252

5353
SDAI_Entity_extent__set::~SDAI_Entity_extent__set() {
54-
delete _buf;
54+
delete[] _buf;
5555
}
5656

5757
void SDAI_Entity_extent__set::Check( int index ) {
@@ -62,7 +62,7 @@ void SDAI_Entity_extent__set::Check( int index ) {
6262
_bufsize = ( index + 1 ) * 2;
6363
newbuf = new SDAI_Entity_extent_ptr[_bufsize];
6464
memmove( newbuf, _buf, _count * sizeof( SDAI_Entity_extent_ptr ) );
65-
delete _buf;
65+
delete[] _buf;
6666
_buf = newbuf;
6767
}
6868
}

src/cleditor/STEPfile.cc

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,8 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou
851851
<< " User Defined Entity in DATA section ignored.\n"
852852
<< "\tData lost: \'!" << objnm << "\': " << tmpbuf
853853
<< endl;
854+
if (scopelist)
855+
delete[] scopelist;
854856
return ENTITY_NULL;
855857
} else {
856858
schnm = schemaName();
@@ -879,6 +881,8 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou
879881
out << "ERROR: instance #" << fileid << " \'" << objnm
880882
<< "\': " << result.UserMsg()
881883
<< ".\n\tData lost: " << tmpbuf << "\n\n";
884+
if (scopelist)
885+
delete[] scopelist;
882886
return ENTITY_NULL;
883887
}
884888
obj -> STEPfile_id = fileid;
@@ -887,6 +891,10 @@ SDAI_Application_instance * STEPfile::CreateInstance( istream & in, ostream & ou
887891
SkipInstance( in, tmpbuf );
888892

889893
ReadTokenSeparator( in );
894+
895+
if (scopelist)
896+
delete[] scopelist;
897+
890898
return obj;
891899
}
892900

@@ -1531,9 +1539,11 @@ void STEPfile::WriteHeaderInstance( SDAI_Application_instance * obj, ostream & o
15311539
void STEPfile::WriteHeaderInstanceFileName( ostream & out ) {
15321540
// Get the FileName instance from _headerInstances
15331541
SDAI_Application_instance * se = 0;
1542+
bool del_se = false;
15341543
se = _headerInstances->GetApplication_instance( "File_Name" );
15351544
if( se == ENTITY_NULL ) {
15361545
se = ( SDAI_Application_instance * )HeaderDefaultFileName();
1546+
del_se = true;
15371547
}
15381548

15391549
//set some of the attribute values at time of output
@@ -1553,6 +1563,9 @@ void STEPfile::WriteHeaderInstanceFileName( ostream & out ) {
15531563

15541564
//output the values to the file
15551565
WriteHeaderInstance( se, out );
1566+
1567+
if (del_se)
1568+
delete se;
15561569
}
15571570

15581571
void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) {
@@ -1563,8 +1576,11 @@ void STEPfile::WriteHeaderInstanceFileDescription( ostream & out ) {
15631576
// ERROR: no File_Name instance in _headerInstances
15641577
// create a File_Name instance
15651578
se = ( SDAI_Application_instance * )HeaderDefaultFileDescription();
1579+
WriteHeaderInstance(se, out);
1580+
delete se;
1581+
} else {
1582+
WriteHeaderInstance( se, out );
15661583
}
1567-
WriteHeaderInstance( se, out );
15681584
}
15691585

15701586
void STEPfile::WriteHeaderInstanceFileSchema( ostream & out ) {
@@ -1575,8 +1591,11 @@ void STEPfile::WriteHeaderInstanceFileSchema( ostream & out ) {
15751591
// ERROR: no File_Name instance in _headerInstances
15761592
// create a File_Name instance
15771593
se = ( SDAI_Application_instance * ) HeaderDefaultFileSchema();
1594+
WriteHeaderInstance( se, out );
1595+
delete se;
1596+
} else {
1597+
WriteHeaderInstance( se, out );
15781598
}
1579-
WriteHeaderInstance( se, out );
15801599
}
15811600

15821601
void STEPfile::WriteData( ostream & out, int writeComments ) {

0 commit comments

Comments
 (0)