summaryrefslogtreecommitdiffstats
path: root/generic/tclOO.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2016-02-04 21:05:02 (GMT)
committerdgp <dgp@users.sourceforge.net>2016-02-04 21:05:02 (GMT)
commit006eb9afe0f425b8dba4ee017492ddded2836d9e (patch)
tree3ccc513c0b38b24c8fb7569d8091762445044a2d /generic/tclOO.c
parent8b4717e9ad0214e985ed2fe6ee6d673b9d1cf603 (diff)
downloadtcl-006eb9afe0f425b8dba4ee017492ddded2836d9e.zip
tcl-006eb9afe0f425b8dba4ee017492ddded2836d9e.tar.gz
tcl-006eb9afe0f425b8dba4ee017492ddded2836d9e.tar.bz2
[cf74deb33c] Plug memleaks in class teardown.
Diffstat (limited to 'generic/tclOO.c')
-rw-r--r--generic/tclOO.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/generic/tclOO.c b/generic/tclOO.c
index 34eb5ad..4697054 100644
--- a/generic/tclOO.c
+++ b/generic/tclOO.c
@@ -913,6 +913,10 @@ ClearMixins(
int i;
Class *mixinPtr;
+ if (clsPtr->mixins.num == 0) {
+ return;
+ }
+
FOREACH(mixinPtr, clsPtr->mixins) {
TclOORemoveFromMixinSubs(clsPtr, mixinPtr);
}
@@ -927,6 +931,10 @@ ClearSuperclasses(
int i;
Class *superPtr;
+ if (clsPtr->superclasses.num == 0) {
+ return;
+ }
+
FOREACH(superPtr, clsPtr->superclasses) {
TclOORemoveFromSubclasses(clsPtr, superPtr);
}
@@ -1002,16 +1010,11 @@ ReleaseClassContents(
*/
FOREACH(mixinSubclassPtr, clsPtr->mixinSubs) {
- if (mixinSubclassPtr == NULL) {
- continue;
- }
if (!Deleted(mixinSubclassPtr->thisPtr)) {
Tcl_DeleteCommandFromToken(interp,
mixinSubclassPtr->thisPtr->command);
}
- if (mixinSubclassPtr->mixins.num) {
- ClearMixins(mixinSubclassPtr);
- }
+ ClearMixins(mixinSubclassPtr);
DelRef(mixinSubclassPtr->thisPtr);
DelRef(mixinSubclassPtr);
}
@@ -1026,15 +1029,13 @@ ReleaseClassContents(
*/
FOREACH(subclassPtr, clsPtr->subclasses) {
- if (subclassPtr == NULL || IsRoot(subclassPtr)) {
+ if (IsRoot(subclassPtr)) {
continue;
}
if (!Deleted(subclassPtr->thisPtr)) {
Tcl_DeleteCommandFromToken(interp, subclassPtr->thisPtr->command);
}
- if (subclassPtr->superclasses.num) {
- ClearSuperclasses(subclassPtr);
- }
+ ClearSuperclasses(subclassPtr);
DelRef(subclassPtr->thisPtr);
DelRef(subclassPtr);
}
@@ -1251,12 +1252,10 @@ ObjectNamespaceDeleted(
clsPtr->filters.num = 0;
}
- if (clsPtr->mixins.num) {
- ClearMixins(clsPtr);
- }
- if (clsPtr->superclasses.num) {
- ClearSuperclasses(clsPtr);
- }
+ ClearMixins(clsPtr);
+
+ ClearSuperclasses(clsPtr);
+
if (clsPtr->subclasses.list) {
ckfree(clsPtr->subclasses.list);
clsPtr->subclasses.num = 0;
@@ -1398,9 +1397,7 @@ TclOORemoveFromSubclasses(
return;
removeSubclass:
- if (Deleted(superPtr->thisPtr)) {
- superPtr->subclasses.list[i] = NULL;
- } else {
+ if (!Deleted(superPtr->thisPtr)) {
superPtr->subclasses.num--;
if (i < superPtr->subclasses.num) {
superPtr->subclasses.list[i] =
@@ -1471,9 +1468,7 @@ TclOORemoveFromMixinSubs(
return;
removeSubclass:
- if (Deleted(superPtr->thisPtr)) {
- superPtr->mixinSubs.list[i] = NULL;
- } else {
+ if (!Deleted(superPtr->thisPtr)) {
superPtr->mixinSubs.num--;
if (i < superPtr->mixinSubs.num) {
superPtr->mixinSubs.list[i] =