Subject: remove stray calls to Tcl_Alloc and friends: the core should only use ckalloc to allow MEM_DEBUG to work properly

From: mig <mig>
Date: Wed, 2 Jan 2013 19:20:54 +0000

---
 ChangeLog                     | 7 +++++++
 generic/tclEnsemble.c         | 2 +-
 generic/tclExecute.c          | 6 +++---
 generic/tclIORTrans.c         | 6 +++---
 generic/tclInt.h              | 2 +-
 generic/tclTomMathInterface.c | 6 +++---
 6 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d814777..289e10a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-01-02  Miguel Sofer  <[email-masked]>
+
+	* generic/tclEnsemble.c:  Remove stray calls to Tcl_Alloc and
+	* generic/tclExecute.c:   friends: the core should only use ckalloc
+	* generic/tclIORTrans.c:  to allow MEM_DEBUG to work properly
+	* generic/tclTomMathInterface.c:
+
 2012-12-31  Donal K. Fellows  <[email-masked]>
 
 	* doc/string.n: Noted the obsolescence of the 'bytelength',
diff --git a/generic/tclEnsemble.c b/generic/tclEnsemble.c
index b76c603..d8fcf97 100644
--- a/generic/tclEnsemble.c
+++ b/generic/tclEnsemble.c
@@ -1579,7 +1579,7 @@ TclMakeEnsemble(
     Tcl_DStringFree(&buf);
     Tcl_DStringFree(&hiddenBuf);
     if (nameParts != NULL) {
-	Tcl_Free((char *) nameParts);
+	ckfree((char *) nameParts);
     }
     return ensemble;
 }
diff --git a/generic/tclExecute.c b/generic/tclExecute.c
index 2b5f713..a9b3fb4 100644
--- a/generic/tclExecute.c
+++ b/generic/tclExecute.c
@@ -1212,7 +1212,7 @@ TclStackFree(
     Tcl_Obj **markerPtr, *marker;
 
     if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
-	Tcl_Free((char *) freePtr);
+	ckfree((char *) freePtr);
 	return;
     }
 
@@ -1272,7 +1272,7 @@ TclStackAlloc(
     int numWords = (numBytes + (sizeof(Tcl_Obj *) - 1))/sizeof(Tcl_Obj *);
 
     if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
-	return (void *) Tcl_Alloc(numBytes);
+	return (void *) ckalloc(numBytes);
     }
 
     return (void *) StackAllocWords(interp, numWords);
@@ -1291,7 +1291,7 @@ TclStackRealloc(
     int numWords;
 
     if (iPtr == NULL || iPtr->execEnvPtr == NULL) {
-	return (void *) Tcl_Realloc((char *) ptr, numBytes);
+	return (void *) ckrealloc((char *) ptr, numBytes);
     }
 
     eePtr = iPtr->execEnvPtr;
diff --git a/generic/tclIORTrans.c b/generic/tclIORTrans.c
index 2b9efb9..1de635f 100644
--- a/generic/tclIORTrans.c
+++ b/generic/tclIORTrans.c
@@ -2942,7 +2942,7 @@ ResultClear(
 	return;
     }
 
-    Tcl_Free((char *) rPtr->buf);
+    ckfree((char *) rPtr->buf);
     rPtr->buf = NULL;
     rPtr->allocated = 0;
 }
@@ -2977,10 +2977,10 @@ ResultAdd(
 
 	if (rPtr->allocated == 0) {
 	    rPtr->allocated = toWrite + RB_INCREMENT;
-	    rPtr->buf = UCHARP(Tcl_Alloc(rPtr->allocated));
+	    rPtr->buf = UCHARP(ckalloc(rPtr->allocated));
 	} else {
 	    rPtr->allocated += toWrite + RB_INCREMENT;
-	    rPtr->buf = UCHARP(Tcl_Realloc((char *) rPtr->buf,
+	    rPtr->buf = UCHARP(ckrealloc((char *) rPtr->buf,
 		    rPtr->allocated));
 	}
     }
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 1d04c82..52f1a32 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -4008,7 +4008,7 @@ typedef const char *TclDTraceStr;
  */
 
 #  define TclAllocObjStorageEx(interp, objPtr) \
-	(objPtr) = (Tcl_Obj *) Tcl_Alloc(sizeof(Tcl_Obj))
+	(objPtr) = (Tcl_Obj *) ckalloc(sizeof(Tcl_Obj))
 
 #  define TclFreeObjStorageEx(interp, objPtr) \
 	ckfree((char *) (objPtr))
diff --git a/generic/tclTomMathInterface.c b/generic/tclTomMathInterface.c
index 775e86b..48db8c3 100644
--- a/generic/tclTomMathInterface.c
+++ b/generic/tclTomMathInterface.c
@@ -111,7 +111,7 @@ extern void *
 TclBNAlloc(
     size_t x)
 {
-    return (void *) Tcl_Alloc((unsigned int) x);
+    return (void *) ckalloc((unsigned int) x);
 }
 
 /*
@@ -135,7 +135,7 @@ TclBNRealloc(
     void *p,
     size_t s)
 {
-    return (void *) Tcl_Realloc((char *) p, (unsigned int) s);
+    return (void *) ckrealloc((char *) p, (unsigned int) s);
 }
 
 /*
@@ -161,7 +161,7 @@ extern void
 TclBNFree(
     void *p)
 {
-    Tcl_Free((char *) p);
+    ckree((char *) p);
 }
 #endif
 
-- 
cgit v0.12