diff options
Diffstat (limited to 'generic/tclLink.c')
-rw-r--r-- | generic/tclLink.c | 116 |
1 files changed, 58 insertions, 58 deletions
diff --git a/generic/tclLink.c b/generic/tclLink.c index 030e471..1352b6f 100644 --- a/generic/tclLink.c +++ b/generic/tclLink.c @@ -25,7 +25,7 @@ * variable. */ -typedef struct Link { +typedef struct { Tcl_Interp *interp; /* Interpreter containing Tcl variable. */ Namespace *nsPtr; /* Namespace containing Tcl variable */ Tcl_Obj *varName; /* Name of variable (must be global). This is @@ -171,7 +171,7 @@ Tcl_LinkVar( return TCL_ERROR; } - linkPtr = ckalloc(sizeof(Link)); + linkPtr = Tcl_Alloc(sizeof(Link)); linkPtr->interp = interp; linkPtr->nsPtr = NULL; linkPtr->varName = Tcl_NewStringObj(varName, -1); @@ -259,7 +259,7 @@ Tcl_LinkArray( return TCL_ERROR; } - linkPtr = ckalloc(sizeof(Link)); + linkPtr = Tcl_Alloc(sizeof(Link)); linkPtr->type = type & ~TCL_LINK_READ_ONLY; linkPtr->numElems = size; if (type & TCL_LINK_READ_ONLY) { @@ -319,7 +319,7 @@ Tcl_LinkArray( */ if (addr == NULL) { - linkPtr->lastValue.aryPtr = ckalloc(linkPtr->bytes); + linkPtr->lastValue.aryPtr = Tcl_Alloc(linkPtr->bytes); linkPtr->flags |= LINK_ALLOC_LAST; addr = (char *) &linkPtr->lastValue.cPtr; } @@ -340,7 +340,7 @@ Tcl_LinkArray( */ if (addr == NULL) { - linkPtr->addr = ckalloc(linkPtr->bytes); + linkPtr->addr = Tcl_Alloc(linkPtr->bytes); linkPtr->flags |= LINK_ALLOC_ADDR; } else { linkPtr->addr = addr; @@ -351,7 +351,7 @@ Tcl_LinkArray( */ if (size > 1) { - linkPtr->lastValue.aryPtr = ckalloc(linkPtr->bytes); + linkPtr->lastValue.aryPtr = Tcl_Alloc(linkPtr->bytes); linkPtr->flags |= LINK_ALLOC_LAST; } @@ -623,20 +623,20 @@ SetInvalidRealFromAny( Tcl_Interp *interp, Tcl_Obj *objPtr) { - const char *str; - const char *endPtr; + size_t length; + const char *str, *endPtr; - str = TclGetString(objPtr); - if ((objPtr->length == 1) && (str[0] == '.')) { + str = TclGetStringFromObj(objPtr, &length); + if ((length == 1) && (str[0] == '.')) { objPtr->typePtr = &invalidRealType; objPtr->internalRep.doubleValue = 0.0; return TCL_OK; } - if (TclParseNumber(NULL, objPtr, NULL, str, objPtr->length, &endPtr, + if (TclParseNumber(NULL, objPtr, NULL, str, length, &endPtr, TCL_PARSE_DECIMAL_ONLY) == TCL_OK) { /* - * If number is followed by [eE][+-]?, then it is an invalid - * double, but it could be the start of a valid double. + * If number is followed by [eE][+-]?, then it is an invalid double, + * but it could be the start of a valid double. */ if (*endPtr == 'e' || *endPtr == 'E') { @@ -659,10 +659,10 @@ SetInvalidRealFromAny( } /* - * This function checks for integer representations, which are valid - * when linking with C variables, but which are invalid in other - * contexts in Tcl. Handled are "+", "-", "", "0x", "0b", "0d" and "0o" - * (upperand lowercase). See bug [39f6304c2e]. + * This function checks for integer representations, which are valid when + * linking with C variables, but which are invalid in other contexts in Tcl. + * Handled are "+", "-", "", "0x", "0b", "0d" and "0o" (upper- and + * lower-case). See bug [39f6304c2e]. */ static int @@ -670,13 +670,14 @@ GetInvalidIntFromObj( Tcl_Obj *objPtr, int *intPtr) { - const char *str = TclGetString(objPtr); + size_t length; + const char *str = TclGetStringFromObj(objPtr, &length); - if ((objPtr->length == 0) || ((objPtr->length == 2) && (str[0] == '0') - && strchr("xXbBoOdD", str[1]))) { + if ((length == 0) || + ((length == 2) && (str[0] == '0') && strchr("xXbBoOdD", str[1]))) { *intPtr = 0; return TCL_OK; - } else if ((objPtr->length == 1) && strchr("+-", str[0])) { + } else if ((length == 1) && strchr("+-", str[0])) { *intPtr = (str[0] == '+'); return TCL_OK; } @@ -684,10 +685,10 @@ GetInvalidIntFromObj( } /* - * This function checks for double representations, which are valid - * when linking with C variables, but which are invalid in other - * contexts in Tcl. Handled are "+", "-", "", ".", "0x", "0b" and "0o" - * (upper- and lowercase) and sequences like "1e-". See bug [39f6304c2e]. + * This function checks for double representations, which are valid when + * linking with C variables, but which are invalid in other contexts in Tcl. + * Handled are "+", "-", "", ".", "0x", "0b" and "0o" (upper- and lower-case) + * and sequences like "1e-". See bug [39f6304c2e]. */ static int @@ -767,7 +768,7 @@ LinkTraceProc( } else if (flags & TCL_TRACE_DESTROYED) { Tcl_ObjSetVar2(interp, linkPtr->varName, NULL, ObjValue(linkPtr), TCL_GLOBAL_ONLY); - Tcl_TraceVar2(interp, Tcl_GetString(linkPtr->varName), NULL, + Tcl_TraceVar2(interp, TclGetString(linkPtr->varName), NULL, TCL_GLOBAL_ONLY|TCL_TRACE_READS|TCL_TRACE_WRITES |TCL_TRACE_UNSETS, LinkTraceProc, linkPtr); } @@ -885,11 +886,10 @@ LinkTraceProc( switch (linkPtr->type) { case TCL_LINK_STRING: - value = TclGetString(valueObj); - valueLength = valueObj->length + 1; + value = TclGetStringFromObj(valueObj, &valueLength); pp = (char **) linkPtr->addr; - *pp = ckrealloc(*pp, valueLength); + *pp = Tcl_Realloc(*pp, ++valueLength); memcpy(*pp, value, valueLength); return NULL; @@ -1283,12 +1283,12 @@ ObjValue( case TCL_LINK_INT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewIntObj(linkPtr->lastValue.iPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.i = LinkedVar(int); @@ -1296,12 +1296,12 @@ ObjValue( case TCL_LINK_WIDE_INT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.wPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.w = LinkedVar(Tcl_WideInt); @@ -1309,12 +1309,12 @@ ObjValue( case TCL_LINK_DOUBLE: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewDoubleObj(linkPtr->lastValue.dPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.d = LinkedVar(double); @@ -1322,12 +1322,12 @@ ObjValue( case TCL_LINK_BOOLEAN: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewBooleanObj(linkPtr->lastValue.iPtr[i] != 0); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.i = LinkedVar(int); @@ -1335,12 +1335,12 @@ ObjValue( case TCL_LINK_CHAR: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewIntObj(linkPtr->lastValue.cPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.c = LinkedVar(char); @@ -1348,12 +1348,12 @@ ObjValue( case TCL_LINK_UCHAR: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewIntObj(linkPtr->lastValue.ucPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.uc = LinkedVar(unsigned char); @@ -1361,12 +1361,12 @@ ObjValue( case TCL_LINK_SHORT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewIntObj(linkPtr->lastValue.sPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.s = LinkedVar(short); @@ -1374,12 +1374,12 @@ ObjValue( case TCL_LINK_USHORT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewIntObj(linkPtr->lastValue.usPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.us = LinkedVar(unsigned short); @@ -1387,12 +1387,12 @@ ObjValue( case TCL_LINK_UINT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.uiPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.ui = LinkedVar(unsigned int); @@ -1401,12 +1401,12 @@ ObjValue( case TCL_LINK_LONG: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.lPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.l = LinkedVar(long); @@ -1414,12 +1414,12 @@ ObjValue( case TCL_LINK_ULONG: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewWideIntObj(linkPtr->lastValue.ulPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.ul = LinkedVar(unsigned long); @@ -1428,12 +1428,12 @@ ObjValue( case TCL_LINK_FLOAT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewDoubleObj(linkPtr->lastValue.fPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.f = LinkedVar(float); @@ -1441,13 +1441,13 @@ ObjValue( case TCL_LINK_WIDE_UINT: if (linkPtr->flags & LINK_ALLOC_LAST) { memcpy(linkPtr->lastValue.aryPtr, linkPtr->addr, linkPtr->bytes); - objv = ckalloc(linkPtr->numElems * sizeof(Tcl_Obj *)); + objv = Tcl_Alloc(linkPtr->numElems * sizeof(Tcl_Obj *)); for (i=0; i < linkPtr->numElems; i++) { objv[i] = Tcl_NewWideIntObj((Tcl_WideInt) linkPtr->lastValue.uwPtr[i]); } resultObj = Tcl_NewListObj(linkPtr->numElems, objv); - ckfree(objv); + Tcl_Free(objv); return resultObj; } linkPtr->lastValue.uw = LinkedVar(Tcl_WideUInt); @@ -1515,12 +1515,12 @@ LinkFree( TclNsDecrRefCount(linkPtr->nsPtr); } if (linkPtr->flags & LINK_ALLOC_ADDR) { - ckfree(linkPtr->addr); + Tcl_Free(linkPtr->addr); } if (linkPtr->flags & LINK_ALLOC_LAST) { - ckfree(linkPtr->lastValue.aryPtr); + Tcl_Free(linkPtr->lastValue.aryPtr); } - ckfree((char *) linkPtr); + Tcl_Free(linkPtr); } /* |