summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--generic/tclInt.h27
2 files changed, 31 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 2cd3ae8..b9ae7b8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2008-07-14 Miguel Sofer <msofer@users.sf.net>
+
+ * generic/tclInt.h: the new macros TclSmallAlloc and TclSmallFree
+ were badly defined under mem debugging [Bug 2017240] (thx das)
+
2008-07-13 Miguel Sofer <msofer@users.sf.net>
NRE implementation [Patch 2017110]
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 9e0f6ce..202f5b8 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -14,7 +14,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.372 2008/07/13 09:03:34 msofer Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.373 2008/07/13 16:07:19 msofer Exp $
*/
#ifndef _TCLINT
@@ -3912,6 +3912,7 @@ MODULE_SCOPE void TclBNInitBignumFromWideUInt(mp_int *bignum,
* DO NOT LET THEM CROSS THREAD BOUNDARIES
*/
+#ifndef TCL_MEM_DEBUG
#define TclSmallAlloc(nbytes, memPtr) \
{ \
Tcl_Obj *objPtr; \
@@ -3931,6 +3932,30 @@ MODULE_SCOPE void TclBNInitBignumFromWideUInt(mp_int *bignum,
TclFreeObjStorage((Tcl_Obj *) memPtr); \
TclIncrObjsFreed()
+#else /* TCL_MEM_DEBUG */
+#define TclSmallAlloc(nbytes, memPtr) \
+ { \
+ Tcl_Obj *objPtr; \
+ switch ((nbytes)>sizeof(Tcl_Obj)) { \
+ case (2 +((nbytes)>sizeof(Tcl_Obj))): \
+ case 3: \
+ case 1: \
+ Tcl_Panic("TclSmallAlloc: nBytes too large!"); \
+ case 0: (void)0; \
+ } \
+ TclNewObj(objPtr); \
+ memPtr = (ClientData) objPtr; \
+ }
+
+#define TclSmallFree(memPtr) \
+ { \
+ Tcl_Obj *objPtr = (Tcl_Obj *) memPtr; \
+ objPtr->bytes = NULL; \
+ objPtr->typePtr = NULL; \
+ objPtr->refCount = 1; \
+ TclDecrRefCount(objPtr); \
+ }
+#endif /* TCL_MEM_DEBUG */
#include "tclPort.h"