diff options
author | dgp <dgp@users.sourceforge.net> | 2016-02-04 21:05:02 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2016-02-04 21:05:02 (GMT) |
commit | 7a58b59b2de1fee906e2c0ad5911bc8e7c262947 (patch) | |
tree | 3ccc513c0b38b24c8fb7569d8091762445044a2d | |
parent | 47c35ac594889f80cd15f4c88f252e7f0fdbd943 (diff) | |
download | tcl-7a58b59b2de1fee906e2c0ad5911bc8e7c262947.zip tcl-7a58b59b2de1fee906e2c0ad5911bc8e7c262947.tar.gz tcl-7a58b59b2de1fee906e2c0ad5911bc8e7c262947.tar.bz2 |
[cf74deb33c] Plug memleaks in class teardown.
-rw-r--r-- | generic/tclOO.c | 39 |
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] = |