diff options
Diffstat (limited to 'generic/tclZipfs.c')
-rw-r--r-- | generic/tclZipfs.c | 160 |
1 files changed, 80 insertions, 80 deletions
diff --git a/generic/tclZipfs.c b/generic/tclZipfs.c index ee166f8..9dcfb4a 100644 --- a/generic/tclZipfs.c +++ b/generic/tclZipfs.c @@ -941,7 +941,7 @@ AllocateZipFile( size_t mountPointNameLength) { size_t size = sizeof(ZipFile) + mountPointNameLength + 1; - ZipFile *zf = (ZipFile *) attemptckalloc(size); + ZipFile *zf = (ZipFile *) Tcl_AttemptAlloc(size); if (!zf) { ZIPFS_MEM_ERROR(interp); @@ -954,7 +954,7 @@ AllocateZipFile( static inline ZipEntry * AllocateZipEntry(void) { - ZipEntry *z = (ZipEntry *) ckalloc(sizeof(ZipEntry)); + ZipEntry *z = (ZipEntry *) Tcl_Alloc(sizeof(ZipEntry)); memset(z, 0, sizeof(ZipEntry)); return z; } @@ -963,7 +963,7 @@ static inline ZipChannel * AllocateZipChannel( Tcl_Interp *interp) { - ZipChannel *zc = (ZipChannel *) attemptckalloc(sizeof(ZipChannel)); + ZipChannel *zc = (ZipChannel *) Tcl_AttemptAlloc(sizeof(ZipChannel)); if (!zc) { ZIPFS_MEM_ERROR(interp); @@ -996,12 +996,12 @@ ZipFSCloseArchive( ZipFile *zf) { if (zf->nameLength) { - ckfree(zf->name); + Tcl_Free(zf->name); } if (zf->isMemBuffer) { /* Pointer to memory */ if (zf->ptrToFree) { - ckfree(zf->ptrToFree); + Tcl_Free(zf->ptrToFree); zf->ptrToFree = NULL; } zf->data = NULL; @@ -1028,7 +1028,7 @@ ZipFSCloseArchive( #endif /* _WIN32 */ if (zf->ptrToFree) { - ckfree(zf->ptrToFree); + Tcl_Free(zf->ptrToFree); zf->ptrToFree = NULL; } if (zf->chan) { @@ -1269,7 +1269,7 @@ ZipFSOpenArchive( ZIPFS_POSIX_ERROR(interp, "seek error"); goto error; } - zf->ptrToFree = zf->data = (unsigned char *) attemptckalloc(zf->length); + zf->ptrToFree = zf->data = (unsigned char *) Tcl_AttemptAlloc(zf->length); if (!zf->ptrToFree) { ZIPFS_MEM_ERROR(interp); goto error; @@ -1500,7 +1500,7 @@ ZipFSCatalogFilesystem( Tcl_CreateExitHandler(ZipfsExitHandler, zf); zf->mountPointLen = strlen(zf->mountPoint); zf->nameLength = strlen(zipname); - zf->name = (char *) ckalloc(zf->nameLength + 1); + zf->name = (char *) Tcl_Alloc(zf->nameLength + 1); memcpy(zf->name, zipname, zf->nameLength + 1); Tcl_SetHashValue(hPtr, zf); if ((zf->passBuf[0] == 0) && pwlen) { @@ -1639,7 +1639,7 @@ ZipFSCatalogFilesystem( hPtr = Tcl_CreateHashEntry(&ZipFS.fileHash, fullpath, &isNew); if (!isNew) { /* should not happen but skip it anyway */ - ckfree(z); + Tcl_Free(z); goto nextent; } @@ -1879,15 +1879,15 @@ TclZipfs_Mount( return TCL_ERROR; } if (ZipFSOpenArchive(interp, zipname, 1, zf) != TCL_OK) { - ckfree(zf); + Tcl_Free(zf); return TCL_ERROR; } if (ZipFSCatalogFilesystem(interp, zf, mountPoint, passwd, zipname) != TCL_OK) { - ckfree(zf); + Tcl_Free(zf); return TCL_ERROR; } - ckfree(zf); + Tcl_Free(zf); return TCL_OK; } @@ -1958,7 +1958,7 @@ TclZipfs_MountBuffer( zf->isMemBuffer = 1; zf->length = datalen; if (copy) { - zf->data = (unsigned char *) attemptckalloc(datalen); + zf->data = (unsigned char *) Tcl_AttemptAlloc(datalen); if (!zf->data) { ZIPFS_MEM_ERROR(interp); return TCL_ERROR; @@ -1975,7 +1975,7 @@ TclZipfs_MountBuffer( } result = ZipFSCatalogFilesystem(interp, zf, mountPoint, NULL, "Memory Buffer"); - ckfree(zf); + Tcl_Free(zf); return result; } @@ -2046,13 +2046,13 @@ TclZipfs_Unmount( Tcl_DeleteHashEntry(hPtr); } if (z->data) { - ckfree(z->data); + Tcl_Free(z->data); } - ckfree(z); + Tcl_Free(z); } ZipFSCloseArchive(interp, zf); Tcl_DeleteExitHandler(ZipfsExitHandler, zf); - ckfree(zf); + Tcl_Free(zf); unmounted = 1; done: @@ -2096,7 +2096,7 @@ ZipFSMountObjCmd( return TCL_ERROR; } if (objc > 1) { - mountPoint = Tcl_GetString(objv[1]); + mountPoint = TclGetString(objv[1]); } if (objc > 2) { zipFileObj = Tcl_FSGetNormalizedPath(interp, objv[2]); @@ -2107,10 +2107,10 @@ ZipFSMountObjCmd( return TCL_ERROR; } Tcl_IncrRefCount(zipFileObj); - zipFile = Tcl_GetString(zipFileObj); + zipFile = TclGetString(zipFileObj); } if (objc > 3) { - password = Tcl_GetString(objv[3]); + password = TclGetString(objv[3]); } result = TclZipfs_Mount(interp, mountPoint, zipFile, password); @@ -2145,7 +2145,7 @@ ZipFSMountBufferObjCmd( { const char *mountPoint; /* Mount point path. */ unsigned char *data; - int length; + size_t length; if (objc > 3) { Tcl_WrongNumArgs(interp, 1, objv, "?mountpoint? ?data?"); @@ -2160,7 +2160,7 @@ ZipFSMountBufferObjCmd( return ret; } - mountPoint = Tcl_GetString(objv[1]); + mountPoint = TclGetString(objv[1]); if (objc < 3) { ReadLock(); DescribeMounted(interp, mountPoint); @@ -2230,7 +2230,7 @@ ZipFSUnmountObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "zipfile"); return TCL_ERROR; } - return TclZipfs_Unmount(interp, Tcl_GetString(objv[1])); + return TclZipfs_Unmount(interp, TclGetString(objv[1])); } /* @@ -2264,7 +2264,7 @@ ZipFSMkKeyObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "password"); return TCL_ERROR; } - pw = Tcl_GetString(objv[1]); + pw = TclGetString(objv[1]); len = strlen(pw); if (len == 0) { return TCL_OK; @@ -2397,7 +2397,7 @@ ZipAddFile( zpathlen = strlen(zpath); if (zpathlen + ZIP_CENTRAL_HEADER_LEN > bufsize) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "path too long for \"%s\"", Tcl_GetString(pathObj))); + "path too long for \"%s\"", TclGetString(pathObj))); ZIPFS_ERROR_CODE(interp, "PATH_LEN"); return TCL_ERROR; } @@ -2436,7 +2436,7 @@ ZipAddFile( } readErrorWithChannelOpen: Tcl_SetObjResult(interp, Tcl_ObjPrintf("read error on \"%s\": %s", - Tcl_GetString(pathObj), Tcl_PosixError(interp))); + TclGetString(pathObj), Tcl_PosixError(interp))); Tcl_Close(interp, in); return TCL_ERROR; } @@ -2448,7 +2448,7 @@ ZipAddFile( } if (Tcl_Seek(in, 0, SEEK_SET) == -1) { Tcl_SetObjResult(interp, Tcl_ObjPrintf("seek error on \"%s\": %s", - Tcl_GetString(pathObj), Tcl_PosixError(interp))); + TclGetString(pathObj), Tcl_PosixError(interp))); Tcl_Close(interp, in); return TCL_ERROR; } @@ -2472,7 +2472,7 @@ ZipAddFile( writeErrorWithChannelOpen: Tcl_SetObjResult(interp, Tcl_ObjPrintf( "write error on \"%s\": %s", - Tcl_GetString(pathObj), Tcl_PosixError(interp))); + TclGetString(pathObj), Tcl_PosixError(interp))); Tcl_Close(interp, in); return TCL_ERROR; } @@ -2547,7 +2547,7 @@ ZipAddFile( if (deflateInit2(&stream, 9, Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "compression init error on \"%s\"", Tcl_GetString(pathObj))); + "compression init error on \"%s\"", TclGetString(pathObj))); ZIPFS_ERROR_CODE(interp, "DEFLATE_INIT"); Tcl_Close(interp, in); return TCL_ERROR; @@ -2568,7 +2568,7 @@ ZipAddFile( len = deflate(&stream, flush); if (len == (size_t) Z_STREAM_ERROR) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "deflate error on \"%s\"", Tcl_GetString(pathObj))); + "deflate error on \"%s\"", TclGetString(pathObj))); ZIPFS_ERROR_CODE(interp, "DEFLATE"); deflateEnd(&stream); Tcl_Close(interp, in); @@ -2651,7 +2651,7 @@ ZipAddFile( hPtr = Tcl_CreateHashEntry(fileHash, zpath, &isNew); if (!isNew) { Tcl_SetObjResult(interp, Tcl_ObjPrintf( - "non-unique path name \"%s\"", Tcl_GetString(pathObj))); + "non-unique path name \"%s\"", TclGetString(pathObj))); ZIPFS_ERROR_CODE(interp, "DUPLICATE_PATH"); return TCL_ERROR; } @@ -2681,14 +2681,14 @@ ZipAddFile( zpathlen, align); if (Tcl_Seek(out, headerStartOffset, SEEK_SET) != headerStartOffset) { Tcl_DeleteHashEntry(hPtr); - ckfree(z); + Tcl_Free(z); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "seek error: %s", Tcl_PosixError(interp))); return TCL_ERROR; } if (Tcl_Write(out, buf, ZIP_LOCAL_HEADER_LEN) != ZIP_LOCAL_HEADER_LEN) { Tcl_DeleteHashEntry(hPtr); - ckfree(z); + Tcl_Free(z); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "write error: %s", Tcl_PosixError(interp))); return TCL_ERROR; @@ -2696,7 +2696,7 @@ ZipAddFile( Tcl_Flush(out); if (Tcl_Seek(out, dataEndOffset, SEEK_SET) != dataEndOffset) { Tcl_DeleteHashEntry(hPtr); - ckfree(z); + Tcl_Free(z); Tcl_SetObjResult(interp, Tcl_ObjPrintf( "seek error: %s", Tcl_PosixError(interp))); return TCL_ERROR; @@ -2766,9 +2766,9 @@ ComputeNameInArchive( int len; if (directNameObj) { - name = Tcl_GetString(directNameObj); + name = TclGetString(directNameObj); } else { - name = Tcl_GetStringFromObj(pathObj, &len); + name = TclGetStringFromObj(pathObj, &len); if (slen > 0) { if ((len <= slen) || (strncmp(strip, name, slen) != 0)) { /* @@ -2853,7 +2853,7 @@ ZipFSMkZipOrImg( passBuf[0] = 0; if (passwordObj != NULL) { - pw = Tcl_GetStringFromObj(passwordObj, &pwlen); + pw = TclGetStringFromObj(passwordObj, &pwlen); if (IsPasswordValid(interp, pw, pwlen) != TCL_OK) { return TCL_ERROR; } @@ -2903,7 +2903,7 @@ ZipFSMkZipOrImg( const char *imgName; // TODO: normalize the origin file name - imgName = (originFile != NULL) ? Tcl_GetString(originFile) : + imgName = (originFile != NULL) ? TclGetString(originFile) : Tcl_GetNameOfExecutable(); if (pwlen) { i = 0; @@ -3009,7 +3009,7 @@ ZipFSMkZipOrImg( Tcl_InitHashTable(&fileHash, TCL_STRING_KEYS); dataStartOffset = Tcl_Tell(out); if (mappingList == NULL && stripPrefix != NULL) { - strip = Tcl_GetStringFromObj(stripPrefix, &slen); + strip = TclGetStringFromObj(stripPrefix, &slen); } for (i = 0; i < (size_t) lobjc; i += (mappingList ? 2 : 1)) { Tcl_Obj *pathObj = lobjv[i]; @@ -3082,7 +3082,7 @@ ZipFSMkZipOrImg( for (hPtr = Tcl_FirstHashEntry(&fileHash, &search); hPtr; hPtr = Tcl_NextHashEntry(&search)) { z = (ZipEntry *) Tcl_GetHashValue(hPtr); - ckfree(z); + Tcl_Free(z); Tcl_DeleteHashEntry(hPtr); } Tcl_DeleteHashTable(&fileHash); @@ -3448,11 +3448,11 @@ ZipFSCanonicalObjCmd( } Tcl_DStringInit(&dPath); if (objc == 2) { - filename = Tcl_GetString(objv[1]); + filename = TclGetString(objv[1]); result = CanonicalPath("", filename, &dPath, 1); } else if (objc == 3) { - mntpoint = Tcl_GetString(objv[1]); - filename = Tcl_GetString(objv[2]); + mntpoint = TclGetString(objv[1]); + filename = TclGetString(objv[2]); result = CanonicalPath(mntpoint, filename, &dPath, 1); } else { int zipfs = 0; @@ -3460,8 +3460,8 @@ ZipFSCanonicalObjCmd( if (Tcl_GetBooleanFromObj(interp, objv[3], &zipfs)) { return TCL_ERROR; } - mntpoint = Tcl_GetString(objv[1]); - filename = Tcl_GetString(objv[2]); + mntpoint = TclGetString(objv[1]); + filename = TclGetString(objv[2]); result = CanonicalPath(mntpoint, filename, &dPath, zipfs); } Tcl_SetObjResult(interp, Tcl_NewStringObj(result, -1)); @@ -3506,7 +3506,7 @@ ZipFSExistsObjCmd( * Prepend ZIPFS_VOLUME to filename, eliding the final / */ - filename = Tcl_GetString(objv[1]); + filename = TclGetString(objv[1]); Tcl_DStringInit(&ds); Tcl_DStringAppend(&ds, ZIPFS_VOLUME, ZIPFS_VOLUME_LEN - 1); Tcl_DStringAppend(&ds, filename, -1); @@ -3553,7 +3553,7 @@ ZipFSInfoObjCmd( Tcl_WrongNumArgs(interp, 1, objv, "filename"); return TCL_ERROR; } - filename = Tcl_GetString(objv[1]); + filename = TclGetString(objv[1]); ReadLock(); z = ZipFSLookup(filename); if (z) { @@ -3621,17 +3621,17 @@ ZipFSListObjCmd( } switch (idx) { case OPT_GLOB: - pattern = Tcl_GetString(objv[2]); + pattern = TclGetString(objv[2]); break; case OPT_REGEXP: - regexp = Tcl_RegExpCompile(interp, Tcl_GetString(objv[2])); + regexp = Tcl_RegExpCompile(interp, TclGetString(objv[2])); if (!regexp) { return TCL_ERROR; } break; } } else if (objc == 2) { - pattern = Tcl_GetString(objv[1]); + pattern = TclGetString(objv[1]); } /* @@ -3829,7 +3829,7 @@ ZipChannelClose( } if (info->iscompr && info->ubuf) { - ckfree(info->ubuf); + Tcl_Free(info->ubuf); info->ubuf = NULL; } if (info->isEncrypted) { @@ -3839,11 +3839,11 @@ ZipChannelClose( if (info->isWriting) { ZipEntry *z = info->zipEntryPtr; unsigned char *newdata = (unsigned char *) - attemptckrealloc(info->ubuf, info->numRead); + Tcl_AttemptRealloc(info->ubuf, info->numRead); if (newdata) { if (z->data) { - ckfree(z->data); + Tcl_Free(z->data); } z->data = newdata; z->numBytes = z->numCompressedBytes = info->numBytes; @@ -3854,13 +3854,13 @@ ZipChannelClose( z->offset = 0; z->crc32 = 0; } else { - ckfree(info->ubuf); + Tcl_Free(info->ubuf); } } WriteLock(); info->zipFilePtr->numOpen--; Unlock(); - ckfree(info); + Tcl_Free(info); return TCL_OK; } @@ -4210,7 +4210,7 @@ ZipChannelOpen( flags |= TCL_WRITABLE; if (InitWritableChannel(interp, info, z, trunc) == TCL_ERROR) { - ckfree(info); + Tcl_Free(info); goto error; } } else if (z->data) { @@ -4228,7 +4228,7 @@ ZipChannelOpen( flags |= TCL_READABLE; if (InitReadableChannel(interp, info, z) == TCL_ERROR) { - ckfree(info); + Tcl_Free(info); goto error; } } @@ -4285,7 +4285,7 @@ InitWritableChannel( info->isWriting = 1; info->maxWrite = ZipFS.wrmax; - info->ubuf = (unsigned char *) attemptckalloc(info->maxWrite); + info->ubuf = (unsigned char *) Tcl_AttemptAlloc(info->maxWrite); if (!info->ubuf) { goto memoryError; } @@ -4347,7 +4347,7 @@ InitWritableChannel( unsigned int j; stream.avail_in -= 12; - cbuf = (unsigned char *) attemptckalloc(stream.avail_in); + cbuf = (unsigned char *) Tcl_AttemptAlloc(stream.avail_in); if (!cbuf) { goto memoryError; } @@ -4370,7 +4370,7 @@ InitWritableChannel( || ((err == Z_OK) && (stream.avail_in == 0))) { if (cbuf) { memset(info->keys, 0, sizeof(info->keys)); - ckfree(cbuf); + Tcl_Free(cbuf); } return TCL_OK; } @@ -4397,7 +4397,7 @@ InitWritableChannel( memoryError: if (info->ubuf) { - ckfree(info->ubuf); + Tcl_Free(info->ubuf); } ZIPFS_MEM_ERROR(interp); return TCL_ERROR; @@ -4405,10 +4405,10 @@ InitWritableChannel( corruptionError: if (cbuf) { memset(info->keys, 0, sizeof(info->keys)); - ckfree(cbuf); + Tcl_Free(cbuf); } if (info->ubuf) { - ckfree(info->ubuf); + Tcl_Free(info->ubuf); } ZIPFS_ERROR(interp, "decompression error"); ZIPFS_ERROR_CODE(interp, "CORRUPT"); @@ -4484,7 +4484,7 @@ InitReadableChannel( stream.avail_in = z->numCompressedBytes; if (info->isEncrypted) { stream.avail_in -= 12; - ubuf = (unsigned char *) attemptckalloc(stream.avail_in); + ubuf = (unsigned char *) Tcl_AttemptAlloc(stream.avail_in); if (!ubuf) { info->ubuf = NULL; goto memoryError; @@ -4499,7 +4499,7 @@ InitReadableChannel( stream.next_in = info->ubuf; } stream.next_out = info->ubuf = (unsigned char *) - attemptckalloc(info->numBytes); + Tcl_AttemptAlloc(info->numBytes); if (!info->ubuf) { goto memoryError; } @@ -4523,7 +4523,7 @@ InitReadableChannel( if (ubuf) { info->isEncrypted = 0; memset(info->keys, 0, sizeof(info->keys)); - ckfree(ubuf); + Tcl_Free(ubuf); } return TCL_OK; } else if (info->isEncrypted) { @@ -4535,7 +4535,7 @@ InitReadableChannel( */ len = z->numCompressedBytes - 12; - ubuf = (unsigned char *) attemptckalloc(len); + ubuf = (unsigned char *) Tcl_AttemptAlloc(len); if (ubuf == NULL) { goto memoryError; } @@ -4552,10 +4552,10 @@ InitReadableChannel( if (ubuf) { info->isEncrypted = 0; memset(info->keys, 0, sizeof(info->keys)); - ckfree(ubuf); + Tcl_Free(ubuf); } if (info->ubuf) { - ckfree(info->ubuf); + Tcl_Free(info->ubuf); } ZIPFS_ERROR(interp, "decompression error"); ZIPFS_ERROR_CODE(interp, "CORRUPT"); @@ -4565,7 +4565,7 @@ InitReadableChannel( if (ubuf) { info->isEncrypted = 0; memset(info->keys, 0, sizeof(info->keys)); - ckfree(ubuf); + Tcl_Free(ubuf); } ZIPFS_MEM_ERROR(interp); return TCL_ERROR; @@ -4695,7 +4695,7 @@ ZipFSOpenFileChannelProc( return NULL; } - return ZipChannelOpen(interp, Tcl_GetStringFromObj(pathPtr, &len), wr, + return ZipChannelOpen(interp, TclGetStringFromObj(pathPtr, &len), wr, trunc); } @@ -4727,7 +4727,7 @@ ZipFSStatProc( if (!pathPtr) { return -1; } - return ZipEntryStat(Tcl_GetStringFromObj(pathPtr, &len), buf); + return ZipEntryStat(TclGetStringFromObj(pathPtr, &len), buf); } /* @@ -4758,7 +4758,7 @@ ZipFSAccessProc( if (!pathPtr) { return -1; } - return ZipEntryAccess(Tcl_GetStringFromObj(pathPtr, &len), mode); + return ZipEntryAccess(TclGetStringFromObj(pathPtr, &len), mode); } /* @@ -4866,13 +4866,13 @@ ZipFSMatchInDirectoryProc( * The prefix that gets prepended to results. */ - prefix = Tcl_GetStringFromObj(pathPtr, &prefixLen); + prefix = TclGetStringFromObj(pathPtr, &prefixLen); /* * The (normalized) path we're searching. */ - path = Tcl_GetString(normPathPtr); + path = TclGetString(normPathPtr); len = normPathPtr->length; Tcl_DStringInit(&dsPref); @@ -4924,7 +4924,7 @@ ZipFSMatchInDirectoryProc( */ l = strlen(pattern); - pat = (char *) ckalloc(len + l + 2); + pat = (char *) Tcl_Alloc(len + l + 2); memcpy(pat, path, len); while ((len > 1) && (pat[len - 1] == '/')) { --len; @@ -4948,7 +4948,7 @@ ZipFSMatchInDirectoryProc( AppendWithPrefix(result, prefixBuf, z->name + strip, -1); } } - ckfree(pat); + Tcl_Free(pat); end: Unlock(); @@ -4988,7 +4988,7 @@ ZipFSMatchMountPoints( Tcl_HashEntry *hPtr; Tcl_HashSearch search; int l, normLength; - const char *path = Tcl_GetStringFromObj(normPathPtr, &normLength); + const char *path = TclGetStringFromObj(normPathPtr, &normLength); size_t len = (size_t) normLength; l = CountSlashes(path); @@ -5070,7 +5070,7 @@ ZipFSPathInFilesystemProc( return -1; } - path = Tcl_GetString(pathPtr); + path = TclGetString(pathPtr); if (strncmp(path, ZIPFS_VOLUME, ZIPFS_VOLUME_LEN) != 0) { return -1; } @@ -5219,7 +5219,7 @@ ZipFSFileAttrsGetProc( if (!pathPtr) { return -1; } - path = Tcl_GetStringFromObj(pathPtr, &len); + path = TclGetStringFromObj(pathPtr, &len); ReadLock(); z = ZipFSLookup(path); if (!z) { |