Index: TODO =================================================================== diff -u -rffd5b8ff74134cc891b9715cf1dd949193065b61 -rd4f9e4f92fc05047b816dfbdccd7e1eed97b725a --- TODO (.../TODO) (revision ffd5b8ff74134cc891b9715cf1dd949193065b61) +++ TODO (.../TODO) (revision d4f9e4f92fc05047b816dfbdccd7e1eed97b725a) @@ -3227,9 +3227,14 @@ a big change) * verified, that nsf runs clean in aolserver/naviserver (all INCR_REF_COUNTS all balanced) + * added paramPtr->name to MEM_COUNT tracing + * renamed NEW_STRING to STRING_NEW + * added STRING_FREE, calling MEM_COUNT macros + * checked all ckfree in nsf.c, everything allocated + is covered by the MEM_COUNT macros - TODO: + - strange refcounting bug in 8.6b2 bug-is-86.tcl where 2 refcounted items are not freed (value:class, issued from nx.tcl around line 120). Compile with DEBUG86B2 @@ -3256,8 +3261,7 @@ - disposition.test: * remove/check exit (see comments in the file) * handle exit from eval/inticmd with proper refcounts - - check ckalloc/ckfree, whether these should be moved to - NEW/FREE. + - nsf-refcounts on TclNamespace are not correct, when namespaces are deleted by tcl. Maybe this is not a problem, but we have to check. Index: generic/nsf.c =================================================================== diff -u -r73d590ba4b6979a5de2606c604329be45fc7bed2 -rd4f9e4f92fc05047b816dfbdccd7e1eed97b725a --- generic/nsf.c (.../nsf.c) (revision 73d590ba4b6979a5de2606c604329be45fc7bed2) +++ generic/nsf.c (.../nsf.c) (revision d4f9e4f92fc05047b816dfbdccd7e1eed97b725a) @@ -7684,7 +7684,7 @@ static void ParamFree(INTERP_DECL Nsf_Param *paramPtr) { /*fprintf(stderr, "ParamFree %p\n", paramPtr);*/ - if (paramPtr->name) ckfree(paramPtr->name); + if (paramPtr->name) {STRING_FREE("paramPtr->name", paramPtr->name);} if (paramPtr->nameObj) {DECR_REF_COUNT(paramPtr->nameObj);} if (paramPtr->defaultValue) {DECR_REF_COUNT(paramPtr->defaultValue);} if (paramPtr->converterName) {DECR_REF_COUNT2("converterNameObj", paramPtr->converterName);} @@ -9607,8 +9607,6 @@ return resultBody; } -#define NEW_STRING(target, p, l) target = ckalloc(l+1); strncpy(target, p, l); *((target)+l) = '\0' - NSF_INLINE static int NoMetaChars(CONST char *pattern) { register char c; @@ -10540,7 +10538,7 @@ size_t l, start, end; /* get parameter name */ - NEW_STRING(paramPtr->name, argString, j); + STRING_NEW(paramPtr->name, argString, j); paramPtr->nameObj = Tcl_NewStringObj(argName, isNonposArgument ? j-1 : j); INCR_REF_COUNT(paramPtr->nameObj); @@ -10573,7 +10571,7 @@ } else { /* no ':', the whole arg is the name, we have no options */ - NEW_STRING(paramPtr->name, argString, length); + STRING_NEW(paramPtr->name, argString, length); if (isNonposArgument) { paramPtr->nameObj = Tcl_NewStringObj(argName, length-1); } else { @@ -21989,7 +21987,7 @@ checkmem checkmemFile"); */ #endif MEM_COUNT_RELEASE(interp); - ckfree(RUNTIME_STATE(interp)); + ckfree((char *) RUNTIME_STATE(interp)); Tcl_Interp_flags(interp) = flags; Tcl_Release(interp); Index: generic/nsfInt.h =================================================================== diff -u -r73d590ba4b6979a5de2606c604329be45fc7bed2 -rd4f9e4f92fc05047b816dfbdccd7e1eed97b725a --- generic/nsfInt.h (.../nsfInt.h) (revision 73d590ba4b6979a5de2606c604329be45fc7bed2) +++ generic/nsfInt.h (.../nsfInt.h) (revision d4f9e4f92fc05047b816dfbdccd7e1eed97b725a) @@ -117,6 +117,10 @@ # define MEM_COUNT_RELEASE(interp) #endif +# define STRING_NEW(target, p, l) target = ckalloc(l+1); strncpy(target, p, l); *((target)+l) = '\0'; \ + MEM_COUNT_ALLOC(#target, target) +# define STRING_FREE(key, p) MEM_COUNT_FREE(key, p); ckfree((p)) + /* * Tries to use gcc __attribute__ unused and mangles the name, so the * attribute could not be used, if declared as unused. @@ -866,6 +870,7 @@ #ifdef NSF_MEM_COUNT void NsfMemCountAlloc(Tcl_Interp *interp, char *id, void *); void NsfMemCountFree(Tcl_Interp *interp, char *id, void *); +void NsfMemCountInit(Tcl_Interp *interp); void NsfMemCountRelease(Tcl_Interp *interp); #endif /* NSF_MEM_COUNT */