summaryrefslogtreecommitdiffstats
path: root/generic/tclThreadTest.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclThreadTest.c')
-rw-r--r--generic/tclThreadTest.c57
1 files changed, 28 insertions, 29 deletions
diff --git a/generic/tclThreadTest.c b/generic/tclThreadTest.c
index ed887db..a5b079a 100644
--- a/generic/tclThreadTest.c
+++ b/generic/tclThreadTest.c
@@ -209,7 +209,6 @@ ThreadObjCmd(
Tcl_Obj *const objv[]) /* Argument objects. */
{
ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey);
- int option;
static const char *const threadOptions[] = {
"cancel", "create", "event", "exit", "id",
"join", "names", "send", "wait", "errorproc",
@@ -219,7 +218,7 @@ ThreadObjCmd(
THREAD_CANCEL, THREAD_CREATE, THREAD_EVENT, THREAD_EXIT,
THREAD_ID, THREAD_JOIN, THREAD_NAMES, THREAD_SEND,
THREAD_WAIT, THREAD_ERRORPROC
- };
+ } option;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
@@ -242,7 +241,7 @@ ThreadObjCmd(
Tcl_MutexUnlock(&threadMutex);
}
- switch ((enum options)option) {
+ switch (option) {
case THREAD_CANCEL: {
Tcl_WideInt id;
const char *result;
@@ -429,10 +428,10 @@ ThreadObjCmd(
Tcl_MutexLock(&threadMutex);
errorThreadId = Tcl_GetCurrentThread();
if (errorProcString) {
- ckfree(errorProcString);
+ Tcl_Free(errorProcString);
}
proc = Tcl_GetString(objv[2]);
- errorProcString = (char *)ckalloc(strlen(proc) + 1);
+ errorProcString = (char *)Tcl_Alloc(strlen(proc) + 1);
strcpy(errorProcString, proc);
Tcl_MutexUnlock(&threadMutex);
return TCL_OK;
@@ -591,7 +590,7 @@ NewTestThread(
* eval'ing, for the case that we exit during evaluation
*/
- threadEvalScript = (char *)ckalloc(strlen(ctrlPtr->script) + 1);
+ threadEvalScript = (char *)Tcl_Alloc(strlen(ctrlPtr->script) + 1);
strcpy(threadEvalScript, ctrlPtr->script);
Tcl_CreateThreadExitHandler(ThreadExitProc, threadEvalScript);
@@ -608,7 +607,7 @@ NewTestThread(
*/
Tcl_Preserve(tsdPtr->interp);
- result = Tcl_EvalEx(tsdPtr->interp, threadEvalScript, -1, 0);
+ result = Tcl_EvalEx(tsdPtr->interp, threadEvalScript, TCL_INDEX_NONE, 0);
if (result != TCL_OK) {
ThreadErrorProc(tsdPtr->interp);
}
@@ -655,10 +654,10 @@ ThreadErrorProc(
errorInfo = Tcl_GetVar2(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY);
if (errorProcString == NULL) {
errChannel = Tcl_GetStdChannel(TCL_STDERR);
- Tcl_WriteChars(errChannel, "Error from thread ", -1);
- Tcl_WriteChars(errChannel, buf, -1);
+ Tcl_WriteChars(errChannel, "Error from thread ", TCL_INDEX_NONE);
+ Tcl_WriteChars(errChannel, buf, TCL_INDEX_NONE);
Tcl_WriteChars(errChannel, "\n", 1);
- Tcl_WriteChars(errChannel, errorInfo, -1);
+ Tcl_WriteChars(errChannel, errorInfo, TCL_INDEX_NONE);
Tcl_WriteChars(errChannel, "\n", 1);
} else {
argv[0] = errorProcString;
@@ -666,7 +665,7 @@ ThreadErrorProc(
argv[2] = errorInfo;
script = Tcl_Merge(3, argv);
ThreadSend(interp, errorThreadId, script, 0);
- ckfree(script);
+ Tcl_Free(script);
}
}
@@ -836,13 +835,13 @@ ThreadSend(
* Create the event for its event queue.
*/
- threadEventPtr = (ThreadEvent*)ckalloc(sizeof(ThreadEvent));
- threadEventPtr->script = (char *)ckalloc(strlen(script) + 1);
+ threadEventPtr = (ThreadEvent*)Tcl_Alloc(sizeof(ThreadEvent));
+ threadEventPtr->script = (char *)Tcl_Alloc(strlen(script) + 1);
strcpy(threadEventPtr->script, script);
if (!wait) {
resultPtr = threadEventPtr->resultPtr = NULL;
} else {
- resultPtr = (ThreadEventResult *)ckalloc(sizeof(ThreadEventResult));
+ resultPtr = (ThreadEventResult *)Tcl_Alloc(sizeof(ThreadEventResult));
threadEventPtr->resultPtr = resultPtr;
/*
@@ -913,19 +912,19 @@ ThreadSend(
if (resultPtr->code != TCL_OK) {
if (resultPtr->errorCode) {
Tcl_SetErrorCode(interp, resultPtr->errorCode, NULL);
- ckfree(resultPtr->errorCode);
+ Tcl_Free(resultPtr->errorCode);
}
if (resultPtr->errorInfo) {
Tcl_AddErrorInfo(interp, resultPtr->errorInfo);
- ckfree(resultPtr->errorInfo);
+ Tcl_Free(resultPtr->errorInfo);
}
}
Tcl_AppendResult(interp, resultPtr->result, NULL);
Tcl_ConditionFinalize(&resultPtr->done);
code = resultPtr->code;
- ckfree(resultPtr->result);
- ckfree(resultPtr);
+ Tcl_Free(resultPtr->result);
+ Tcl_Free(resultPtr);
return code;
}
@@ -983,7 +982,7 @@ ThreadCancel(
Tcl_MutexUnlock(&threadMutex);
Tcl_ResetResult(interp);
return Tcl_CancelEval(tsdPtr->interp,
- (result != NULL) ? Tcl_NewStringObj(result, -1) : NULL, 0, flags);
+ (result != NULL) ? Tcl_NewStringObj(result, TCL_INDEX_NONE) : NULL, 0, flags);
}
/*
@@ -1033,18 +1032,18 @@ ThreadEventProc(
}
result = Tcl_GetStringResult(interp);
}
- ckfree(threadEventPtr->script);
+ Tcl_Free(threadEventPtr->script);
if (resultPtr) {
Tcl_MutexLock(&threadMutex);
resultPtr->code = code;
- resultPtr->result = (char *)ckalloc(strlen(result) + 1);
+ resultPtr->result = (char *)Tcl_Alloc(strlen(result) + 1);
strcpy(resultPtr->result, result);
if (errorCode != NULL) {
- resultPtr->errorCode = (char *)ckalloc(strlen(errorCode) + 1);
+ resultPtr->errorCode = (char *)Tcl_Alloc(strlen(errorCode) + 1);
strcpy(resultPtr->errorCode, errorCode);
}
if (errorInfo != NULL) {
- resultPtr->errorInfo = (char *)ckalloc(strlen(errorInfo) + 1);
+ resultPtr->errorInfo = (char *)Tcl_Alloc(strlen(errorInfo) + 1);
strcpy(resultPtr->errorInfo, errorInfo);
}
Tcl_ConditionNotify(&resultPtr->done);
@@ -1078,7 +1077,7 @@ ThreadFreeProc(
void *clientData)
{
if (clientData) {
- ckfree(clientData);
+ Tcl_Free(clientData);
}
}
@@ -1105,7 +1104,7 @@ ThreadDeleteEvent(
TCL_UNUSED(void *))
{
if (eventPtr->proc == ThreadEventProc) {
- ckfree(((ThreadEvent *) eventPtr)->script);
+ Tcl_Free(((ThreadEvent *) eventPtr)->script);
return 1;
}
@@ -1151,14 +1150,14 @@ ThreadExitProc(
if (self == errorThreadId) {
if (errorProcString) { /* Extra safety */
- ckfree(errorProcString);
+ Tcl_Free(errorProcString);
errorProcString = NULL;
}
errorThreadId = 0;
}
if (threadEvalScript) {
- ckfree(threadEvalScript);
+ Tcl_Free(threadEvalScript);
threadEvalScript = NULL;
}
Tcl_DeleteEvents((Tcl_EventDeleteProc *) ThreadDeleteEvent, NULL);
@@ -1181,7 +1180,7 @@ ThreadExitProc(
}
resultPtr->nextPtr = resultPtr->prevPtr = 0;
resultPtr->eventPtr->resultPtr = NULL;
- ckfree(resultPtr);
+ Tcl_Free(resultPtr);
} else if (resultPtr->dstThreadId == self) {
/*
* Dang. The target is going away. Unblock the caller. The result
@@ -1191,7 +1190,7 @@ ThreadExitProc(
const char *msg = "target thread died";
- resultPtr->result = (char *)ckalloc(strlen(msg) + 1);
+ resultPtr->result = (char *)Tcl_Alloc(strlen(msg) + 1);
strcpy(resultPtr->result, msg);
resultPtr->code = TCL_ERROR;
Tcl_ConditionNotify(&resultPtr->done);