diff options
author | Miguel Sofer <miguel.sofer@gmail.com> | 2002-08-14 17:31:42 (GMT) |
---|---|---|
committer | Miguel Sofer <miguel.sofer@gmail.com> | 2002-08-14 17:31:42 (GMT) |
commit | 4b5d9d688fcfa02e6cbce01873ea40fa7fc62bde (patch) | |
tree | 8f131b477e23d20a986cef5ee5d879ec86f8f4f1 /generic/tclObj.c | |
parent | e5da04bb09ebf77a289165ed344ef33a59883585 (diff) | |
download | tcl-4b5d9d688fcfa02e6cbce01873ea40fa7fc62bde.zip tcl-4b5d9d688fcfa02e6cbce01873ea40fa7fc62bde.tar.gz tcl-4b5d9d688fcfa02e6cbce01873ea40fa7fc62bde.tar.bz2 |
* generic/tclInt.h:
* generic/tclObj.c: (code cleanup) factored the parts in the macros
TclNewObj() / TclDecrRefCount() into a common part for all
memory allocators and two new macros TclAllocObjStorage() /
TclFreeObjStorage() that are specific to each allocator and fully
describe the differences. Removed allocator-specific code from
tclObj.c by using the macros.
Diffstat (limited to 'generic/tclObj.c')
-rw-r--r-- | generic/tclObj.c | 44 |
1 files changed, 7 insertions, 37 deletions
diff --git a/generic/tclObj.c b/generic/tclObj.c index 7ecf030..2eb61fd 100644 --- a/generic/tclObj.c +++ b/generic/tclObj.c @@ -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: tclObj.c,v 1.38 2002/08/07 17:13:56 msofer Exp $ + * RCS: @(#) $Id: tclObj.c,v 1.39 2002/08/14 17:31:43 msofer Exp $ */ #include "tclInt.h" @@ -516,30 +516,11 @@ Tcl_NewObj() register Tcl_Obj *objPtr; /* - * Allocate the object using the list of free Tcl_Obj structs - * we maintain. + * Use the macro defined in tclInt.h - it will use the + * correct allocator. */ - Tcl_MutexLock(&tclObjMutex); -#ifdef PURIFY - objPtr = (Tcl_Obj *) Tcl_Ckalloc(sizeof(Tcl_Obj)); -#elif defined(TCL_THREADS) && defined(USE_THREAD_ALLOC) - objPtr = TclThreadAllocObj(); -#else - if (tclFreeObjList == NULL) { - TclAllocateFreeObjects(); - } - objPtr = tclFreeObjList; - tclFreeObjList = (Tcl_Obj *) tclFreeObjList->internalRep.otherValuePtr; -#endif - objPtr->refCount = 0; - objPtr->bytes = tclEmptyStringRep; - objPtr->length = 0; - objPtr->typePtr = NULL; -#ifdef TCL_COMPILE_STATS - tclObjsAlloced++; -#endif /* TCL_COMPILE_STATS */ - Tcl_MutexUnlock(&tclObjMutex); + TclNewObj(objPtr); return objPtr; } #endif /* TCL_MEM_DEBUG */ @@ -583,24 +564,13 @@ Tcl_DbNewObj(file, line) register Tcl_Obj *objPtr; /* - * If debugging Tcl's memory usage, allocate the object using ckalloc. - * Otherwise, allocate it using the list of free Tcl_Obj structs we - * maintain. + * Use the macro defined in tclInt.h - it will use the + * correct allocator. */ - objPtr = (Tcl_Obj *) Tcl_DbCkalloc(sizeof(Tcl_Obj), file, line); - objPtr->refCount = 0; - objPtr->bytes = tclEmptyStringRep; - objPtr->length = 0; - objPtr->typePtr = NULL; -#ifdef TCL_COMPILE_STATS - Tcl_MutexLock(&tclObjMutex); - tclObjsAlloced++; - Tcl_MutexUnlock(&tclObjMutex); -#endif /* TCL_COMPILE_STATS */ + TclDbNewObj(objPtr, file, line); return objPtr; } - #else /* if not TCL_MEM_DEBUG */ Tcl_Obj * |