diff options
author | hobbs <hobbs> | 2001-10-19 23:47:57 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2001-10-19 23:47:57 (GMT) |
commit | 4bbed5c99798bd29697e69be4f9a13e190bc4b3f (patch) | |
tree | a2f8816e5811941c69394aa8b4f40ca76181167c /generic/tclInt.h | |
parent | 634c2bfa56e31d7200d571e3ad4645f54356310d (diff) | |
download | tcl-4bbed5c99798bd29697e69be4f9a13e190bc4b3f.zip tcl-4bbed5c99798bd29697e69be4f9a13e190bc4b3f.tar.gz tcl-4bbed5c99798bd29697e69be4f9a13e190bc4b3f.tar.bz2 |
added -DPURIFY object allocation option
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r-- | generic/tclInt.h | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h index 887c7fc..f2e5b8d 100644 --- a/generic/tclInt.h +++ b/generic/tclInt.h @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclInt.h,v 1.42.2.2 2001/09/01 23:06:28 davygrvy Exp $ + * RCS: @(#) $Id: tclInt.h,v 1.42.2.3 2001/10/19 23:47:57 hobbs Exp $ */ #ifndef _TCLINT @@ -2101,6 +2101,37 @@ EXTERN int TclCompileWhileCmd _ANSI_ARGS_((Tcl_Interp *interp, TclIncrObjsFreed(); \ } +#elif defined(PURIFY) + +/* + * The PURIFY mode is like the regular mode, but instead of doing block + * Tcl_Obj allocation and keeping a freed list for efficiency, it always + * allocates and frees a single Tcl_Obj so that tools like Purify can + * better track memory leaks + */ + +# define TclNewObj(objPtr) \ + (objPtr) = (Tcl_Obj *) Tcl_Ckalloc(sizeof(Tcl_Obj)); \ + (objPtr)->refCount = 0; \ + (objPtr)->bytes = tclEmptyStringRep; \ + (objPtr)->length = 0; \ + (objPtr)->typePtr = NULL; \ + TclIncrObjsAllocated(); + +# define TclDecrRefCount(objPtr) \ + if (--(objPtr)->refCount <= 0) { \ + if (((objPtr)->bytes != NULL) \ + && ((objPtr)->bytes != tclEmptyStringRep)) { \ + ckfree((char *) (objPtr)->bytes); \ + } \ + if (((objPtr)->typePtr != NULL) \ + && ((objPtr)->typePtr->freeIntRepProc != NULL)) { \ + (objPtr)->typePtr->freeIntRepProc(objPtr); \ + } \ + ckfree((char *) (objPtr)); \ + TclIncrObjsFreed(); \ + } + #else /* not TCL_MEM_DEBUG */ #ifdef TCL_THREADS |