Skip to content

Commit a1d6b25

Browse files
committed
Fixed some memory leaks in ExpDict.cc.
* TypeDescriptor::_where_rules never got destroyed. * Where_rule__list, Uniqueness_rule__set and Global_rule__set never destroyed their content. * Inverse_attributeList never destroyed it's content.
1 parent 626bb73 commit a1d6b25

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

src/clstepcore/ExpDict.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,8 @@ Where_rule__list::Where_rule__list( int defaultSize ) {
10251025
}
10261026

10271027
Where_rule__list::~Where_rule__list() {
1028+
Clear();
1029+
10281030
delete _buf;
10291031
}
10301032

@@ -1102,6 +1104,9 @@ int Where_rule__list::Count() {
11021104
}
11031105

11041106
void Where_rule__list::Clear() {
1107+
for ( int i = 0; i < _count ; i ++ ) {
1108+
delete _buf[i];
1109+
}
11051110
_count = 0;
11061111
}
11071112

@@ -1130,6 +1135,8 @@ Uniqueness_rule__set::Uniqueness_rule__set( int defaultSize ) {
11301135
}
11311136

11321137
Uniqueness_rule__set::~Uniqueness_rule__set() {
1138+
Clear();
1139+
11331140
delete _buf;
11341141
}
11351142

@@ -1207,6 +1214,9 @@ int Uniqueness_rule__set::Count() {
12071214
}
12081215

12091216
void Uniqueness_rule__set::Clear() {
1217+
for ( int i = 0; i < _count; i ++ ) {
1218+
delete _buf[i];
1219+
}
12101220
_count = 0;
12111221
}
12121222

@@ -1247,6 +1257,7 @@ Global_rule__set::Global_rule__set( int defaultSize ) {
12471257
}
12481258

12491259
Global_rule__set::~Global_rule__set() {
1260+
Clear();
12501261
delete _buf;
12511262
}
12521263

@@ -1324,6 +1335,9 @@ int Global_rule__set::Count() {
13241335
}
13251336

13261337
void Global_rule__set::Clear() {
1338+
for ( int i = 0; i < _count; i ++ ) {
1339+
delete _buf[i];
1340+
}
13271341
_count = 0;
13281342
}
13291343

src/clstepcore/ExpDict.inline.cc

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ AttrDescLinkNode::AttrDescLinkNode() {
123123
}
124124

125125
AttrDescLinkNode::~AttrDescLinkNode() {
126+
if ( _attrDesc ) {
127+
delete _attrDesc;
128+
}
126129
}
127130

128131
AttrDescItr::AttrDescItr( const AttrDescriptorList & adList ) : adl( adList ) {
@@ -143,6 +146,13 @@ Inverse_attributeList::Inverse_attributeList() {
143146
}
144147

145148
Inverse_attributeList::~Inverse_attributeList() {
149+
Inverse_attributeLinkNode *node;
150+
151+
node = ( Inverse_attributeLinkNode* ) head;
152+
while ( node ) {
153+
delete node->Inverse_attr();
154+
node = ( Inverse_attributeLinkNode* ) node->NextNode();
155+
}
146156
}
147157

148158
Inverse_attributeLinkNode * Inverse_attributeList::AddNode( Inverse_attribute * ad ) {
@@ -211,6 +221,12 @@ TypeDescriptor::TypeDescriptor
211221
_where_rules( 0 ) {
212222
}
213223

224+
TypeDescriptor::~TypeDescriptor() {
225+
if ( _where_rules ) {
226+
delete _where_rules;
227+
}
228+
}
229+
214230
/**
215231
* Determines the current name of this. Normally, this is simply _name.
216232
* If "schnm" is set to a value, however, then this function becomes a

0 commit comments

Comments
 (0)