Tcl Source Code

Check-in [b087783022]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:plug memleaks
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | core-8-6-branch
Files: files | file ages | folders
SHA3-256: b087783022c9d6a4b77b5f258529cd242c7f17b597df8ed8385d8e2e462f4454
User & Date: dgp 2018-03-11 21:15:27
Context
2018-03-12
02:48
It is confusingly stupid to use variable "length" to hold an actual length in part of a routine, and... check-in: 4d996dc6aa user: dgp tags: core-8-6-branch
2018-03-11
21:29
merge 8.6 check-in: 23c46c8cd1 user: dgp tags: core-8-branch
21:15
plug memleaks check-in: b087783022 user: dgp tags: core-8-6-branch
21:14
Prevent leaks of the Object structs of oo::object and oo::class. check-in: 722088eb1f user: dgp tags: memleak
12:14
plug memleak of constructed package requirement. check-in: 70bb82f088 user: dgp tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to generic/tclOO.c.

548
549
550
551
552
553
554









555
556
557
558
559
560
561
...
930
931
932
933
934
935
936

937
938















939
940
941
942
943
944
945
    ClientData clientData,	/* Pointer to the OO system foundation
				 * structure. */
    Tcl_Interp *interp)		/* The interpreter containing the OO system
				 * foundation. */
{
    Foundation *fPtr = GetFoundation(interp);










    TclDecrRefCount(fPtr->unknownMethodNameObj);
    TclDecrRefCount(fPtr->constructorName);
    TclDecrRefCount(fPtr->destructorName);
    TclDecrRefCount(fPtr->clonedName);
    TclDecrRefCount(fPtr->defineName);
    ckfree(fPtr);
}
................................................................................
    if (clsPtr->filters.num) {
	Tcl_Obj *filterObj;

	FOREACH(filterObj, clsPtr->filters) {
	    TclDecrRefCount(filterObj);
	}
	ckfree(clsPtr->filters.list);

	clsPtr->filters.num = 0;
    }
















    /*
     * Squelch our metadata.
     */

    if (clsPtr->metadataPtr != NULL) {
	Tcl_ObjectMetadataType *metadataTypePtr;






>
>
>
>
>
>
>
>
>







 







>


>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
...
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
    ClientData clientData,	/* Pointer to the OO system foundation
				 * structure. */
    Tcl_Interp *interp)		/* The interpreter containing the OO system
				 * foundation. */
{
    Foundation *fPtr = GetFoundation(interp);

    /*
     * Crude mechanism to avoid leaking the Object struct of the
     * foundation components oo::object and oo::class
     *
     * Should probably be replaced with something more elegantly designed.
     */
    while (TclOODecrRefCount(fPtr->objectCls->thisPtr) == 0) {};
    while (TclOODecrRefCount(fPtr->classCls->thisPtr) == 0) {};

    TclDecrRefCount(fPtr->unknownMethodNameObj);
    TclDecrRefCount(fPtr->constructorName);
    TclDecrRefCount(fPtr->destructorName);
    TclDecrRefCount(fPtr->clonedName);
    TclDecrRefCount(fPtr->defineName);
    ckfree(fPtr);
}
................................................................................
    if (clsPtr->filters.num) {
	Tcl_Obj *filterObj;

	FOREACH(filterObj, clsPtr->filters) {
	    TclDecrRefCount(filterObj);
	}
	ckfree(clsPtr->filters.list);
	clsPtr->filters.list = NULL;
	clsPtr->filters.num = 0;
    }

    /*
     * Squelch our instances.
     */

    if (clsPtr->instances.num) {
	Object *oPtr;

	FOREACH(oPtr, clsPtr->instances) {
	    TclOODecrRefCount(oPtr);
	}
	ckfree(clsPtr->instances.list);
	clsPtr->instances.list = NULL;
	clsPtr->instances.num = 0;
    }

    /*
     * Squelch our metadata.
     */

    if (clsPtr->metadataPtr != NULL) {
	Tcl_ObjectMetadataType *metadataTypePtr;