summaryrefslogtreecommitdiffstats
path: root/generic/tclPkg.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2018-09-01 22:01:35 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2018-09-01 22:01:35 (GMT)
commitba417d3ce6d273a724c772efed9f3fbca65b94a8 (patch)
tree954bdbecb4cb9c3a063b6ad4b237f6c7a7c05ae1 /generic/tclPkg.c
parente663097026638d349d2ac63a28f5c5fcd6f15677 (diff)
parent195f90c9510d639c9807253136edfce377cbeef9 (diff)
downloadtcl-ba417d3ce6d273a724c772efed9f3fbca65b94a8.zip
tcl-ba417d3ce6d273a724c772efed9f3fbca65b94a8.tar.gz
tcl-ba417d3ce6d273a724c772efed9f3fbca65b94a8.tar.bz2
Change ckalloc and friends to Tcl_Alloc and friends. Add two defines, TCL_IO_FAILURE and TCL_NO_LENGTH (experimental, still open to be renamed following discussion)
Diffstat (limited to 'generic/tclPkg.c')
-rw-r--r--generic/tclPkg.c110
1 files changed, 55 insertions, 55 deletions
diff --git a/generic/tclPkg.c b/generic/tclPkg.c
index 0c726c2..2791fc9 100644
--- a/generic/tclPkg.c
+++ b/generic/tclPkg.c
@@ -112,7 +112,7 @@ static int TclNRPackageObjCmdCleanup(ClientData data[], Tcl_Interp *interp, int
*/
#define DupBlock(v,s,len) \
- ((v) = ckalloc(len), memcpy((v),(s),(len)))
+ ((v) = Tcl_Alloc(len), memcpy((v),(s),(len)))
#define DupString(v,s) \
do { \
size_t local__len = strlen(s) + 1; \
@@ -175,13 +175,13 @@ Tcl_PkgProvideEx(
NULL) != TCL_OK) {
return TCL_ERROR;
} else if (CheckVersionAndConvert(interp, version, &vi, NULL) != TCL_OK) {
- ckfree(pvi);
+ Tcl_Free(pvi);
return TCL_ERROR;
}
res = CompareVersions(pvi, vi, NULL);
- ckfree(pvi);
- ckfree(vi);
+ Tcl_Free(pvi);
+ Tcl_Free(vi);
if (res == 0) {
if (clientData != NULL) {
@@ -233,7 +233,7 @@ static void PkgFilesCleanupProc(ClientData clientData,
while (pkgFiles->names) {
PkgName *name = pkgFiles->names;
pkgFiles->names = name->nextPtr;
- ckfree(name);
+ Tcl_Free(name);
}
entry = Tcl_FirstHashEntry(&pkgFiles->table, &search);
while (entry) {
@@ -242,7 +242,7 @@ static void PkgFilesCleanupProc(ClientData clientData,
entry = Tcl_NextHashEntry(&search);
}
Tcl_DeleteHashTable(&pkgFiles->table);
- ckfree(pkgFiles);
+ Tcl_Free(pkgFiles);
return;
}
@@ -251,7 +251,7 @@ void *TclInitPkgFiles(Tcl_Interp *interp)
/* If assocdata "tclPkgFiles" doesn't exist yet, create it */
PkgFiles *pkgFiles = Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
if (!pkgFiles) {
- pkgFiles = ckalloc(sizeof(PkgFiles));
+ pkgFiles = Tcl_Alloc(sizeof(PkgFiles));
pkgFiles->names = NULL;
Tcl_InitHashTable(&pkgFiles->table, TCL_STRING_KEYS);
Tcl_SetAssocData(interp, "tclPkgFiles", PkgFilesCleanupProc, pkgFiles);
@@ -445,7 +445,7 @@ PkgRequireCore(ClientData data[], Tcl_Interp *interp, int result)
if (code != TCL_OK) {
return code;
}
- reqPtr = ckalloc(sizeof(Require));
+ reqPtr = Tcl_Alloc(sizeof(Require));
Tcl_NRAddCallback(interp, PkgRequireCoreCleanup, reqPtr, NULL, NULL, NULL);
reqPtr->clientDataPtr = data[3];
reqPtr->name = name;
@@ -543,7 +543,7 @@ PkgRequireCoreFinal(ClientData data[], Tcl_Interp *interp, int result) {
CheckVersionAndConvert(interp, reqPtr->pkgPtr->version, &pkgVersionI, NULL);
satisfies = SomeRequirementSatisfied(pkgVersionI, reqc, reqv);
- ckfree(pkgVersionI);
+ Tcl_Free(pkgVersionI);
if (!satisfies) {
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -567,7 +567,7 @@ PkgRequireCoreFinal(ClientData data[], Tcl_Interp *interp, int result) {
static int
PkgRequireCoreCleanup(ClientData data[], Tcl_Interp *interp, int result) {
- ckfree(data[0]);
+ Tcl_Free(data[0]);
return result;
}
@@ -629,7 +629,7 @@ SelectPackage(ClientData data[], Tcl_Interp *interp, int result) {
if (reqc > 0) {
satisfies = SomeRequirementSatisfied(availVersion, reqc, reqv);
if (!satisfies) {
- ckfree(availVersion);
+ Tcl_Free(availVersion);
availVersion = NULL;
continue;
}
@@ -647,7 +647,7 @@ SelectPackage(ClientData data[], Tcl_Interp *interp, int result) {
* The version of the package sought is better than the
* currently selected version.
*/
- ckfree(bestVersion);
+ Tcl_Free(bestVersion);
bestVersion = NULL;
goto newbest;
}
@@ -660,7 +660,7 @@ SelectPackage(ClientData data[], Tcl_Interp *interp, int result) {
}
if (!availStable) {
- ckfree(availVersion);
+ Tcl_Free(availVersion);
availVersion = NULL;
continue;
}
@@ -677,7 +677,7 @@ SelectPackage(ClientData data[], Tcl_Interp *interp, int result) {
* This stable version of the package sought is better
* than the currently selected stable version.
*/
- ckfree(bestStableVersion);
+ Tcl_Free(bestStableVersion);
bestStableVersion = NULL;
goto newstable;
}
@@ -688,7 +688,7 @@ SelectPackage(ClientData data[], Tcl_Interp *interp, int result) {
CheckVersionAndConvert(interp, bestStablePtr->version, &bestStableVersion, NULL);
}
- ckfree(availVersion);
+ Tcl_Free(availVersion);
availVersion = NULL;
} /* end for */
@@ -697,12 +697,12 @@ SelectPackage(ClientData data[], Tcl_Interp *interp, int result) {
*/
if (bestVersion != NULL) {
- ckfree(bestVersion);
+ Tcl_Free(bestVersion);
bestVersion = NULL;
}
if (bestStableVersion != NULL) {
- ckfree(bestStableVersion);
+ Tcl_Free(bestStableVersion);
bestStableVersion = NULL;
}
@@ -736,7 +736,7 @@ SelectPackage(ClientData data[], Tcl_Interp *interp, int result) {
pkgFiles = TclInitPkgFiles(interp);
/* Push "ifneeded" package name in "tclPkgFiles" assocdata. */
- pkgName = ckalloc(sizeof(PkgName) + strlen(name));
+ pkgName = Tcl_Alloc(sizeof(PkgName) + strlen(name));
pkgName->nextPtr = pkgFiles->names;
strcpy(pkgName->name, name);
pkgFiles->names = pkgName;
@@ -762,7 +762,7 @@ SelectPackageFinal(ClientData data[], Tcl_Interp *interp, int result) {
PkgFiles *pkgFiles = Tcl_GetAssocData(interp, "tclPkgFiles", NULL);
PkgName *pkgName = pkgFiles->names;
pkgFiles->names = pkgName->nextPtr;
- ckfree(pkgName);
+ Tcl_Free(pkgName);
reqPtr->pkgPtr = FindPackage(interp, name);
if (result == TCL_OK) {
@@ -783,13 +783,13 @@ SelectPackageFinal(ClientData data[], Tcl_Interp *interp, int result) {
result = TCL_ERROR;
} else if (CheckVersionAndConvert(interp,
versionToProvide, &vi, NULL) != TCL_OK) {
- ckfree(pvi);
+ Tcl_Free(pvi);
result = TCL_ERROR;
} else {
int res = CompareVersions(pvi, vi, NULL);
- ckfree(pvi);
- ckfree(vi);
+ Tcl_Free(pvi);
+ Tcl_Free(vi);
if (res != 0) {
result = TCL_ERROR;
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
@@ -834,7 +834,7 @@ SelectPackageFinal(ClientData data[], Tcl_Interp *interp, int result) {
*/
if (reqPtr->pkgPtr->version != NULL) {
- ckfree(reqPtr->pkgPtr->version);
+ Tcl_Free(reqPtr->pkgPtr->version);
reqPtr->pkgPtr->version = NULL;
}
reqPtr->pkgPtr->clientData = NULL;
@@ -1036,7 +1036,7 @@ TclNRPackageObjCmd(
pkgPtr = Tcl_GetHashValue(hPtr);
Tcl_DeleteHashEntry(hPtr);
if (pkgPtr->version != NULL) {
- ckfree(pkgPtr->version);
+ Tcl_Free(pkgPtr->version);
}
while (pkgPtr->availPtr != NULL) {
availPtr = pkgPtr->availPtr;
@@ -1047,9 +1047,9 @@ TclNRPackageObjCmd(
Tcl_EventuallyFree(availPtr->pkgIndex, TCL_DYNAMIC);
availPtr->pkgIndex = NULL;
}
- ckfree(availPtr);
+ Tcl_Free(availPtr);
}
- ckfree(pkgPtr);
+ Tcl_Free(pkgPtr);
}
break;
}
@@ -1069,7 +1069,7 @@ TclNRPackageObjCmd(
if (objc == 4) {
hPtr = Tcl_FindHashEntry(&iPtr->packageTable, argv2);
if (hPtr == NULL) {
- ckfree(argv3i);
+ Tcl_Free(argv3i);
return TCL_OK;
}
pkgPtr = Tcl_GetHashValue(hPtr);
@@ -1082,16 +1082,16 @@ TclNRPackageObjCmd(
prevPtr = availPtr, availPtr = availPtr->nextPtr) {
if (CheckVersionAndConvert(interp, availPtr->version, &avi,
NULL) != TCL_OK) {
- ckfree(argv3i);
+ Tcl_Free(argv3i);
return TCL_ERROR;
}
res = CompareVersions(avi, argv3i, NULL);
- ckfree(avi);
+ Tcl_Free(avi);
if (res == 0){
if (objc == 4) {
- ckfree(argv3i);
+ Tcl_Free(argv3i);
Tcl_SetObjResult(interp,
Tcl_NewStringObj(availPtr->script, -1));
return TCL_OK;
@@ -1104,13 +1104,13 @@ TclNRPackageObjCmd(
break;
}
}
- ckfree(argv3i);
+ Tcl_Free(argv3i);
if (objc == 4) {
return TCL_OK;
}
if (availPtr == NULL) {
- availPtr = ckalloc(sizeof(PkgAvail));
+ availPtr = Tcl_Alloc(sizeof(PkgAvail));
availPtr->pkgIndex = NULL;
DupBlock(availPtr->version, argv3, (unsigned) length + 1);
@@ -1295,7 +1295,7 @@ TclNRPackageObjCmd(
}
} else if (objc == 3) {
if (iPtr->packageUnknown != NULL) {
- ckfree(iPtr->packageUnknown);
+ Tcl_Free(iPtr->packageUnknown);
}
argv2 = TclGetStringFromObj(objv[2], &length);
if (argv2[0] == 0) {
@@ -1356,7 +1356,7 @@ TclNRPackageObjCmd(
if (CheckVersionAndConvert(interp, argv2, &iva, NULL) != TCL_OK ||
CheckVersionAndConvert(interp, argv3, &ivb, NULL) != TCL_OK) {
if (iva != NULL) {
- ckfree(iva);
+ Tcl_Free(iva);
}
/*
@@ -1372,8 +1372,8 @@ TclNRPackageObjCmd(
Tcl_SetObjResult(interp,
Tcl_NewIntObj(CompareVersions(iva, ivb, NULL)));
- ckfree(iva);
- ckfree(ivb);
+ Tcl_Free(iva);
+ Tcl_Free(ivb);
break;
case PKG_VERSIONS:
if (objc != 3) {
@@ -1407,12 +1407,12 @@ TclNRPackageObjCmd(
if (CheckVersionAndConvert(interp, argv2, &argv2i, NULL) != TCL_OK) {
return TCL_ERROR;
} else if (CheckAllRequirements(interp, objc-3, objv+3) != TCL_OK) {
- ckfree(argv2i);
+ Tcl_Free(argv2i);
return TCL_ERROR;
}
satisfies = SomeRequirementSatisfied(argv2i, objc-3, objv+3);
- ckfree(argv2i);
+ Tcl_Free(argv2i);
Tcl_SetObjResult(interp, Tcl_NewBooleanObj(satisfies));
break;
@@ -1460,7 +1460,7 @@ FindPackage(
hPtr = Tcl_CreateHashEntry(&iPtr->packageTable, name, &isNew);
if (isNew) {
- pkgPtr = ckalloc(sizeof(Package));
+ pkgPtr = Tcl_Alloc(sizeof(Package));
pkgPtr->version = NULL;
pkgPtr->availPtr = NULL;
pkgPtr->clientData = NULL;
@@ -1501,7 +1501,7 @@ TclFreePackageInfo(
hPtr != NULL; hPtr = Tcl_NextHashEntry(&search)) {
pkgPtr = Tcl_GetHashValue(hPtr);
if (pkgPtr->version != NULL) {
- ckfree(pkgPtr->version);
+ Tcl_Free(pkgPtr->version);
}
while (pkgPtr->availPtr != NULL) {
availPtr = pkgPtr->availPtr;
@@ -1512,13 +1512,13 @@ TclFreePackageInfo(
Tcl_EventuallyFree(availPtr->pkgIndex, TCL_DYNAMIC);
availPtr->pkgIndex = NULL;
}
- ckfree(availPtr);
+ Tcl_Free(availPtr);
}
- ckfree(pkgPtr);
+ Tcl_Free(pkgPtr);
}
Tcl_DeleteHashTable(&iPtr->packageTable);
if (iPtr->packageUnknown != NULL) {
- ckfree(iPtr->packageUnknown);
+ Tcl_Free(iPtr->packageUnknown);
}
}
@@ -1558,7 +1558,7 @@ CheckVersionAndConvert(
* 4* assuming that each char is a separator (a,b become ' -x ').
* 4+ to have spce for an additional -2 at the end
*/
- char *ibuf = ckalloc(4 + 4*strlen(string));
+ char *ibuf = Tcl_Alloc(4 + 4*strlen(string));
char *ip = ibuf;
/*
@@ -1626,7 +1626,7 @@ CheckVersionAndConvert(
if (internal != NULL) {
*internal = ibuf;
} else {
- ckfree(ibuf);
+ Tcl_Free(ibuf);
}
if (stable != NULL) {
*stable = !hasunstable;
@@ -1635,7 +1635,7 @@ CheckVersionAndConvert(
}
error:
- ckfree(ibuf);
+ Tcl_Free(ibuf);
Tcl_SetObjResult(interp, Tcl_ObjPrintf(
"expected version number but got \"%s\"", string));
Tcl_SetErrorCode(interp, "TCL", "VALUE", "VERSION", NULL);
@@ -1909,7 +1909,7 @@ CheckRequirement(
* Exactly one dash is present. Copy the string, split at the location of
* dash and check that both parts are versions. Note that the max part can
* be empty. Also note that the string allocated with strdup() must be
- * freed with free() and not ckfree().
+ * freed with free() and not Tcl_Free().
*/
DupString(buf, string);
@@ -1920,11 +1920,11 @@ CheckRequirement(
if ((CheckVersionAndConvert(interp, buf, NULL, NULL) != TCL_OK) ||
((*dash != '\0') &&
(CheckVersionAndConvert(interp, dash, NULL, NULL) != TCL_OK))) {
- ckfree(buf);
+ Tcl_Free(buf);
return TCL_ERROR;
}
- ckfree(buf);
+ Tcl_Free(buf);
return TCL_OK;
}
@@ -2089,7 +2089,7 @@ RequirementSatisfied(
strcat(reqi, " -2");
res = CompareVersions(havei, reqi, &thisIsMajor);
satisfied = (res == 0) || ((res == 1) && !thisIsMajor);
- ckfree(reqi);
+ Tcl_Free(reqi);
return satisfied;
}
@@ -2113,8 +2113,8 @@ RequirementSatisfied(
CheckVersionAndConvert(NULL, buf, &min, NULL);
strcat(min, " -2");
satisfied = (CompareVersions(havei, min, NULL) >= 0);
- ckfree(min);
- ckfree(buf);
+ Tcl_Free(min);
+ Tcl_Free(buf);
return satisfied;
}
@@ -2136,9 +2136,9 @@ RequirementSatisfied(
(CompareVersions(havei, max, NULL) < 0));
}
- ckfree(min);
- ckfree(max);
- ckfree(buf);
+ Tcl_Free(min);
+ Tcl_Free(max);
+ Tcl_Free(buf);
return satisfied;
}