summaryrefslogtreecommitdiffstats
path: root/generic/tclZlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'generic/tclZlib.c')
-rw-r--r--generic/tclZlib.c212
1 files changed, 111 insertions, 101 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c
index 9bad36d..d05d774 100644
--- a/generic/tclZlib.c
+++ b/generic/tclZlib.c
@@ -64,7 +64,7 @@ typedef struct {
Tcl_Obj *inData, *outData; /* Input / output buffers (lists) */
Tcl_Obj *currentInput; /* Pointer to what is currently being
* inflated. */
- int outPos;
+ size_t outPos;
int mode; /* Either TCL_ZLIB_STREAM_DEFLATE or
* TCL_ZLIB_STREAM_INFLATE. */
int format; /* Flags from the TCL_ZLIB_FORMAT_* */
@@ -178,7 +178,7 @@ static void ConvertError(Tcl_Interp *interp, int code,
uLong adler);
static Tcl_Obj * ConvertErrorToList(int code, uLong adler);
static inline int Deflate(z_streamp strm, void *bufferPtr,
- int bufferSize, int flush, int *writtenPtr);
+ size_t bufferSize, int flush, size_t *writtenPtr);
static void ExtractHeader(gz_header *headerPtr, Tcl_Obj *dictObj);
static int GenerateHeader(Tcl_Interp *interp, Tcl_Obj *dictObj,
GzipHeader *headerPtr, int *extraSizePtr);
@@ -440,8 +440,8 @@ GenerateHeader(
if (GetValue(interp, dictObj, "comment", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
- valueStr = TclGetStringFromObj(value, &len);
- Tcl_UtfToExternal(NULL, latin1enc, valueStr, len, 0, NULL,
+ valueStr = TclGetString(value);
+ Tcl_UtfToExternal(NULL, latin1enc, valueStr, value->length, 0, NULL,
headerPtr->nativeCommentBuf, MAX_COMMENT_LEN-1, NULL, &len,
NULL);
headerPtr->nativeCommentBuf[len] = '\0';
@@ -461,8 +461,8 @@ GenerateHeader(
if (GetValue(interp, dictObj, "filename", &value) != TCL_OK) {
goto error;
} else if (value != NULL) {
- valueStr = TclGetStringFromObj(value, &len);
- Tcl_UtfToExternal(NULL, latin1enc, valueStr, len, 0, NULL,
+ valueStr = TclGetString(value);
+ Tcl_UtfToExternal(NULL, latin1enc, valueStr, value->length, 0, NULL,
headerPtr->nativeFilenameBuf, MAXPATHLEN-1, NULL, &len, NULL);
headerPtr->nativeFilenameBuf[len] = '\0';
headerPtr->header.name = (Bytef *) headerPtr->nativeFilenameBuf;
@@ -590,10 +590,10 @@ SetInflateDictionary(
Tcl_Obj *compDictObj)
{
if (compDictObj != NULL) {
- int length;
- unsigned char *bytes = Tcl_GetByteArrayFromObj(compDictObj, &length);
+ size_t length;
+ unsigned char *bytes = TclGetByteArrayFromObj(compDictObj, &length);
- return inflateSetDictionary(strm, bytes, (unsigned) length);
+ return inflateSetDictionary(strm, bytes, length);
}
return Z_OK;
}
@@ -604,10 +604,10 @@ SetDeflateDictionary(
Tcl_Obj *compDictObj)
{
if (compDictObj != NULL) {
- int length;
- unsigned char *bytes = Tcl_GetByteArrayFromObj(compDictObj, &length);
+ size_t length;
+ unsigned char *bytes = TclGetByteArrayFromObj(compDictObj, &length);
- return deflateSetDictionary(strm, bytes, (unsigned) length);
+ return deflateSetDictionary(strm, bytes, length);
}
return Z_OK;
}
@@ -616,14 +616,14 @@ static inline int
Deflate(
z_streamp strm,
void *bufferPtr,
- int bufferSize,
+ size_t bufferSize,
int flush,
- int *writtenPtr)
+ size_t *writtenPtr)
{
int e;
- strm->next_out = (Bytef *) bufferPtr;
- strm->avail_out = (unsigned) bufferSize;
+ strm->next_out = bufferPtr;
+ strm->avail_out = bufferSize;
e = deflate(strm, flush);
if (writtenPtr != NULL) {
*writtenPtr = bufferSize - strm->avail_out;
@@ -635,7 +635,7 @@ static inline void
AppendByteArray(
Tcl_Obj *listObj,
void *buffer,
- int size)
+ size_t size)
{
if (size > 0) {
Tcl_Obj *baObj = Tcl_NewByteArrayObj((unsigned char *) buffer, size);
@@ -697,11 +697,11 @@ Tcl_ZlibStreamInit(
case TCL_ZLIB_FORMAT_GZIP:
wbits = WBITS_GZIP;
if (dictObj) {
- gzHeaderPtr = ckalloc(sizeof(GzipHeader));
+ gzHeaderPtr = Tcl_Alloc(sizeof(GzipHeader));
memset(gzHeaderPtr, 0, sizeof(GzipHeader));
if (GenerateHeader(interp, dictObj, gzHeaderPtr,
NULL) != TCL_OK) {
- ckfree(gzHeaderPtr);
+ Tcl_Free(gzHeaderPtr);
return TCL_ERROR;
}
}
@@ -731,7 +731,7 @@ Tcl_ZlibStreamInit(
break;
case TCL_ZLIB_FORMAT_GZIP:
wbits = WBITS_GZIP;
- gzHeaderPtr = ckalloc(sizeof(GzipHeader));
+ gzHeaderPtr = Tcl_Alloc(sizeof(GzipHeader));
memset(gzHeaderPtr, 0, sizeof(GzipHeader));
gzHeaderPtr->header.name = (Bytef *)
gzHeaderPtr->nativeFilenameBuf;
@@ -757,7 +757,7 @@ Tcl_ZlibStreamInit(
" TCL_ZLIB_STREAM_INFLATE");
}
- zshPtr = ckalloc(sizeof(ZlibStreamHandle));
+ zshPtr = Tcl_Alloc(sizeof(ZlibStreamHandle));
zshPtr->interp = interp;
zshPtr->mode = mode;
zshPtr->format = format;
@@ -857,9 +857,9 @@ Tcl_ZlibStreamInit(
Tcl_DecrRefCount(zshPtr->compDictObj);
}
if (zshPtr->gzHeaderPtr) {
- ckfree(zshPtr->gzHeaderPtr);
+ Tcl_Free(zshPtr->gzHeaderPtr);
}
- ckfree(zshPtr);
+ Tcl_Free(zshPtr);
return TCL_ERROR;
}
@@ -970,10 +970,10 @@ ZlibStreamCleanup(
Tcl_DecrRefCount(zshPtr->compDictObj);
}
if (zshPtr->gzHeaderPtr) {
- ckfree(zshPtr->gzHeaderPtr);
+ Tcl_Free(zshPtr->gzHeaderPtr);
}
- ckfree(zshPtr);
+ Tcl_Free(zshPtr);
}
/*
@@ -1188,7 +1188,8 @@ Tcl_ZlibStreamPut(
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
char *dataTmp = NULL;
- int e, size, outSize, toStore;
+ int e;
+ size_t size, outSize, toStore;
if (zshPtr->streamEnd) {
if (zshPtr->interp) {
@@ -1200,7 +1201,7 @@ Tcl_ZlibStreamPut(
}
if (zshPtr->mode == TCL_ZLIB_STREAM_DEFLATE) {
- zshPtr->stream.next_in = Tcl_GetByteArrayFromObj(data, &size);
+ zshPtr->stream.next_in = TclGetByteArrayFromObj(data, &size);
zshPtr->stream.avail_in = size;
/*
@@ -1231,7 +1232,7 @@ Tcl_ZlibStreamPut(
if (outSize > BUFFER_SIZE_LIMIT) {
outSize = BUFFER_SIZE_LIMIT;
}
- dataTmp = ckalloc(outSize);
+ dataTmp = Tcl_Alloc(outSize);
while (1) {
e = Deflate(&zshPtr->stream, dataTmp, outSize, flush, &toStore);
@@ -1245,7 +1246,7 @@ Tcl_ZlibStreamPut(
* case. [Bug b26e38a3e4] [Tk Bug 10f2e7872b]
*/
- if ((e != Z_BUF_ERROR) && (e != Z_OK || toStore < outSize)) {
+ if ((e != Z_BUF_ERROR) && (e != Z_OK || (size_t)(unsigned)toStore < outSize)) {
if ((e == Z_OK) || (flush == Z_FINISH && e == Z_STREAM_END)) {
break;
}
@@ -1265,7 +1266,7 @@ Tcl_ZlibStreamPut(
if (outSize < BUFFER_SIZE_LIMIT) {
outSize = BUFFER_SIZE_LIMIT;
/* There may be *lots* of data left to output... */
- dataTmp = ckrealloc(dataTmp, outSize);
+ dataTmp = Tcl_Realloc(dataTmp, outSize);
}
}
@@ -1274,7 +1275,7 @@ Tcl_ZlibStreamPut(
*/
AppendByteArray(zshPtr->outData, dataTmp, toStore);
- ckfree(dataTmp);
+ Tcl_Free(dataTmp);
} else {
/*
* This is easy. Just append to the inData list.
@@ -1307,14 +1308,15 @@ int
Tcl_ZlibStreamGet(
Tcl_ZlibStream zshandle, /* As obtained from Tcl_ZlibStreamInit */
Tcl_Obj *data, /* A place to append the data. */
- int count) /* Number of bytes to grab as a maximum, you
+ size_t count) /* Number of bytes to grab as a maximum, you
* may get less! */
{
ZlibStreamHandle *zshPtr = (ZlibStreamHandle *) zshandle;
- int e, i, listLen, itemLen, dataPos = 0;
+ int e, i, listLen;
+ size_t itemLen, dataPos = 0;
Tcl_Obj *itemObj;
unsigned char *dataPtr, *itemPtr;
- int existing;
+ size_t existing;
/*
* Getting beyond the of stream, just return empty string.
@@ -1324,10 +1326,10 @@ Tcl_ZlibStreamGet(
return TCL_OK;
}
- (void) Tcl_GetByteArrayFromObj(data, &existing);
+ (void) TclGetByteArrayFromObj(data, &existing);
if (zshPtr->mode == TCL_ZLIB_STREAM_INFLATE) {
- if (count == -1) {
+ if (count == (size_t)-1) {
/*
* The only safe thing to do is restict to 65k. We might cause a
* panic for out of memory if we just kept growing the buffer.
@@ -1367,7 +1369,7 @@ Tcl_ZlibStreamGet(
if (Tcl_IsShared(itemObj)) {
itemObj = Tcl_DuplicateObj(itemObj);
}
- itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
+ itemPtr = TclGetByteArrayFromObj(itemObj, &itemLen);
Tcl_IncrRefCount(itemObj);
zshPtr->currentInput = itemObj;
zshPtr->stream.next_in = itemPtr;
@@ -1439,7 +1441,7 @@ Tcl_ZlibStreamGet(
if (Tcl_IsShared(itemObj)) {
itemObj = Tcl_DuplicateObj(itemObj);
}
- itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
+ itemPtr = TclGetByteArrayFromObj(itemObj, &itemLen);
Tcl_IncrRefCount(itemObj);
zshPtr->currentInput = itemObj;
zshPtr->stream.next_in = itemPtr;
@@ -1484,11 +1486,11 @@ Tcl_ZlibStreamGet(
}
} else {
Tcl_ListObjLength(NULL, zshPtr->outData, &listLen);
- if (count == -1) {
+ if (count == (size_t)-1) {
count = 0;
for (i=0; i<listLen; i++) {
Tcl_ListObjIndex(NULL, zshPtr->outData, i, &itemObj);
- itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
+ itemPtr = TclGetByteArrayFromObj(itemObj, &itemLen);
if (i == 0) {
count += itemLen - zshPtr->outPos;
} else {
@@ -1513,9 +1515,9 @@ Tcl_ZlibStreamGet(
*/
Tcl_ListObjIndex(NULL, zshPtr->outData, 0, &itemObj);
- itemPtr = Tcl_GetByteArrayFromObj(itemObj, &itemLen);
- if (itemLen-zshPtr->outPos >= count-dataPos) {
- unsigned len = count - dataPos;
+ itemPtr = TclGetByteArrayFromObj(itemObj, &itemLen);
+ if (itemLen-zshPtr->outPos >= (size_t)(count-dataPos)) {
+ size_t len = count - dataPos;
memcpy(dataPtr + dataPos, itemPtr + zshPtr->outPos, len);
zshPtr->outPos += len;
@@ -1524,7 +1526,7 @@ Tcl_ZlibStreamGet(
zshPtr->outPos = 0;
}
} else {
- unsigned len = itemLen - zshPtr->outPos;
+ size_t len = itemLen - zshPtr->outPos;
memcpy(dataPtr + dataPos, itemPtr + zshPtr->outPos, len);
dataPos += len;
@@ -1560,7 +1562,8 @@ Tcl_ZlibDeflate(
int level,
Tcl_Obj *gzipHeaderDictObj)
{
- int wbits = 0, inLen = 0, e = 0, extraSize = 0;
+ int wbits = 0, e = 0, extraSize = 0;
+ size_t inLen = 0;
Byte *inData = NULL;
z_stream stream;
GzipHeader header;
@@ -1620,9 +1623,9 @@ Tcl_ZlibDeflate(
* to the deflate command.
*/
- inData = Tcl_GetByteArrayFromObj(data, &inLen);
+ inData = TclGetByteArrayFromObj(data, &inLen);
memset(&stream, 0, sizeof(z_stream));
- stream.avail_in = (uInt) inLen;
+ stream.avail_in = inLen;
stream.next_in = inData;
/*
@@ -1707,10 +1710,11 @@ Tcl_ZlibInflate(
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
- int bufferSize,
+ size_t bufferSize,
Tcl_Obj *gzipHeaderDictObj)
{
- int wbits = 0, inLen = 0, e = 0, newBufferSize;
+ int wbits = 0, e = 0;
+ size_t inLen = 0, newBufferSize;
Byte *inData = NULL, *outData = NULL, *newOutData = NULL;
z_stream stream;
gz_header header, *headerPtr = NULL;
@@ -1750,15 +1754,15 @@ Tcl_ZlibInflate(
if (gzipHeaderDictObj) {
headerPtr = &header;
memset(headerPtr, 0, sizeof(gz_header));
- nameBuf = ckalloc(MAXPATHLEN);
+ nameBuf = Tcl_Alloc(MAXPATHLEN);
header.name = (Bytef *) nameBuf;
header.name_max = MAXPATHLEN - 1;
- commentBuf = ckalloc(MAX_COMMENT_LEN);
+ commentBuf = Tcl_Alloc(MAX_COMMENT_LEN);
header.comment = (Bytef *) commentBuf;
header.comm_max = MAX_COMMENT_LEN - 1;
}
- inData = Tcl_GetByteArrayFromObj(data, &inLen);
+ inData = TclGetByteArrayFromObj(data, &inLen);
if (bufferSize < 1) {
/*
* Start with a buffer (up to) 3 times the size of the input data.
@@ -1776,7 +1780,7 @@ Tcl_ZlibInflate(
TclNewObj(obj);
outData = Tcl_SetByteArrayLength(obj, bufferSize);
memset(&stream, 0, sizeof(z_stream));
- stream.avail_in = (uInt) inLen+1; /* +1 because zlib can "over-request"
+ stream.avail_in = inLen+1; /* +1 because zlib can "over-request"
* input (but ignore it!) */
stream.next_in = inData;
stream.avail_out = bufferSize;
@@ -1859,8 +1863,8 @@ Tcl_ZlibInflate(
ExtractHeader(&header, gzipHeaderDictObj);
SetValue(gzipHeaderDictObj, "size",
Tcl_NewLongObj((long) stream.total_out));
- ckfree(nameBuf);
- ckfree(commentBuf);
+ Tcl_Free(nameBuf);
+ Tcl_Free(commentBuf);
}
Tcl_SetObjResult(interp, obj);
return TCL_OK;
@@ -1869,10 +1873,10 @@ Tcl_ZlibInflate(
TclDecrRefCount(obj);
ConvertError(interp, e, stream.adler);
if (nameBuf) {
- ckfree(nameBuf);
+ Tcl_Free(nameBuf);
}
if (commentBuf) {
- ckfree(commentBuf);
+ Tcl_Free(commentBuf);
}
return TCL_ERROR;
}
@@ -1891,19 +1895,19 @@ unsigned int
Tcl_ZlibCRC32(
unsigned int crc,
const unsigned char *buf,
- int len)
+ size_t len)
{
/* Nothing much to do, just wrap the crc32(). */
- return crc32(crc, (Bytef *) buf, (unsigned) len);
+ return crc32(crc, (Bytef *) buf, len);
}
unsigned int
Tcl_ZlibAdler32(
unsigned int adler,
const unsigned char *buf,
- int len)
+ size_t len)
{
- return adler32(adler, (Bytef *) buf, (unsigned) len);
+ return adler32(adler, (Bytef *) buf, len);
}
/*
@@ -1923,8 +1927,9 @@ ZlibCmd(
int objc,
Tcl_Obj *const objv[])
{
- int command, dlen, i, option, level = -1;
- unsigned start, buffersize = 0;
+ int command, i, option, level = -1;
+ size_t dlen, start, buffersize = 0;
+ Tcl_WideInt wideLen;
Byte *data;
Tcl_Obj *headerDictObj;
const char *extraInfoStr = NULL;
@@ -1961,7 +1966,7 @@ ZlibCmd(
if (objc < 4) {
start = Tcl_ZlibAdler32(0, NULL, 0);
}
- data = Tcl_GetByteArrayFromObj(objv[2], &dlen);
+ data = TclGetByteArrayFromObj(objv[2], &dlen);
Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)
(uLong) Tcl_ZlibAdler32(start, data, dlen)));
return TCL_OK;
@@ -1978,7 +1983,7 @@ ZlibCmd(
if (objc < 4) {
start = Tcl_ZlibCRC32(0, NULL, 0);
}
- data = Tcl_GetByteArrayFromObj(objv[2], &dlen);
+ data = TclGetByteArrayFromObj(objv[2], &dlen);
Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt)
(uLong) Tcl_ZlibCRC32(start, data, dlen)));
return TCL_OK;
@@ -2071,14 +2076,15 @@ ZlibCmd(
return TCL_ERROR;
}
if (objc > 3) {
- if (Tcl_GetIntFromObj(interp, objv[3],
- (int *) &buffersize) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3],
+ &wideLen) != TCL_OK) {
return TCL_ERROR;
}
- if (buffersize < MIN_NONSTREAM_BUFFER_SIZE
- || buffersize > MAX_BUFFER_SIZE) {
+ if (wideLen < MIN_NONSTREAM_BUFFER_SIZE
+ || wideLen > MAX_BUFFER_SIZE) {
goto badBuffer;
}
+ buffersize = wideLen;
}
return Tcl_ZlibInflate(interp, TCL_ZLIB_FORMAT_RAW, objv[2],
buffersize, NULL);
@@ -2090,14 +2096,15 @@ ZlibCmd(
return TCL_ERROR;
}
if (objc > 3) {
- if (Tcl_GetIntFromObj(interp, objv[3],
- (int *) &buffersize) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[3],
+ &wideLen) != TCL_OK) {
return TCL_ERROR;
}
- if (buffersize < MIN_NONSTREAM_BUFFER_SIZE
- || buffersize > MAX_BUFFER_SIZE) {
+ if (wideLen < MIN_NONSTREAM_BUFFER_SIZE
+ || wideLen > MAX_BUFFER_SIZE) {
goto badBuffer;
}
+ buffersize = wideLen;
}
return Tcl_ZlibInflate(interp, TCL_ZLIB_FORMAT_ZLIB, objv[2],
buffersize, NULL);
@@ -2121,14 +2128,15 @@ ZlibCmd(
}
switch (option) {
case 0:
- if (Tcl_GetIntFromObj(interp, objv[i+1],
- (int *) &buffersize) != TCL_OK) {
+ if (Tcl_GetWideIntFromObj(interp, objv[i+1],
+ &wideLen) != TCL_OK) {
return TCL_ERROR;
}
- if (buffersize < MIN_NONSTREAM_BUFFER_SIZE
- || buffersize > MAX_BUFFER_SIZE) {
+ if (wideLen < MIN_NONSTREAM_BUFFER_SIZE
+ || wideLen > MAX_BUFFER_SIZE) {
goto badBuffer;
}
+ buffersize = wideLen;
break;
case 1:
headerVarObj = objv[i+1];
@@ -2733,7 +2741,7 @@ ZlibStreamAddCmd(
if (compDictObj != NULL) {
int len;
- (void) Tcl_GetByteArrayFromObj(compDictObj, &len);
+ (void) TclGetByteArrayFromObj(compDictObj, &len);
if (len == 0) {
compDictObj = NULL;
}
@@ -2835,9 +2843,9 @@ ZlibStreamPutCmd(
*/
if (compDictObj != NULL) {
- int len;
+ size_t len;
- (void) Tcl_GetByteArrayFromObj(compDictObj, &len);
+ (void) TclGetByteArrayFromObj(compDictObj, &len);
if (len == 0) {
compDictObj = NULL;
}
@@ -2896,7 +2904,8 @@ ZlibTransformClose(
Tcl_Interp *interp)
{
ZlibChannelData *cd = instanceData;
- int e, written, result = TCL_OK;
+ int e, result = TCL_OK;
+ size_t written;
/*
* Delete the support timer.
@@ -2960,14 +2969,14 @@ ZlibTransformClose(
Tcl_DStringFree(&cd->decompressed);
if (cd->inBuffer) {
- ckfree(cd->inBuffer);
+ Tcl_Free(cd->inBuffer);
cd->inBuffer = NULL;
}
if (cd->outBuffer) {
- ckfree(cd->outBuffer);
+ Tcl_Free(cd->outBuffer);
cd->outBuffer = NULL;
}
- ckfree(cd);
+ Tcl_Free(cd);
return result;
}
@@ -3033,13 +3042,13 @@ ZlibTransformInput(
* Three cases here:
* 1. Got some data from the underlying channel (readBytes > 0) so
* it should be fed through the decompression engine.
- * 2. Got an error (readBytes < 0) which we should report up except
+ * 2. Got an error (readBytes == -1) which we should report up except
* for the case where we can convert it to a short read.
* 3. Got an end-of-data from EOF or blocking (readBytes == 0). If
* it is EOF, try flushing the data out of the decompressor.
*/
- if (readBytes < 0) {
+ if (readBytes == -1) {
/* See ReflectInput() in tclIORTrans.c */
if (Tcl_InputBlocked(cd->parent) && (gotBytes > 0)) {
@@ -3105,7 +3114,8 @@ ZlibTransformOutput(
ZlibChannelData *cd = instanceData;
Tcl_DriverOutputProc *outProc =
Tcl_ChannelOutputProc(Tcl_GetChannelType(cd->parent));
- int e, produced;
+ int e;
+ size_t produced;
Tcl_Obj *errObj;
if (cd->mode == TCL_ZLIB_STREAM_INFLATE) {
@@ -3167,7 +3177,8 @@ ZlibTransformFlush(
ZlibChannelData *cd,
int flushType)
{
- int e, len;
+ int e;
+ size_t len;
cd->outStream.avail_in = 0;
do {
@@ -3239,7 +3250,7 @@ ZlibTransformSetOption( /* not used */
TclNewStringObj(compDictObj, value, strlen(value));
Tcl_IncrRefCount(compDictObj);
- (void) Tcl_GetByteArrayFromObj(compDictObj, NULL);
+ Tcl_GetByteArrayFromObj(compDictObj, NULL);
if (cd->compDictObj) {
TclDecrRefCount(cd->compDictObj);
}
@@ -3386,10 +3397,9 @@ ZlibTransformGetOption(
}
} else {
if (cd->compDictObj) {
- int len;
- const char *str = TclGetStringFromObj(cd->compDictObj, &len);
+ const char *str = TclGetString(cd->compDictObj);
- Tcl_DStringAppend(dsPtr, str, len);
+ Tcl_DStringAppend(dsPtr, str, cd->compDictObj->length);
}
return TCL_OK;
}
@@ -3590,7 +3600,7 @@ ZlibStackChannelTransform(
* dictionary (not dictObj!) to use if
* necessary. */
{
- ZlibChannelData *cd = ckalloc(sizeof(ZlibChannelData));
+ ZlibChannelData *cd = Tcl_Alloc(sizeof(ZlibChannelData));
Tcl_Channel chan;
int wbits = 0;
@@ -3650,7 +3660,7 @@ ZlibStackChannelTransform(
goto error;
}
cd->inAllocated = DEFAULT_BUFFER_SIZE;
- cd->inBuffer = ckalloc(cd->inAllocated);
+ cd->inBuffer = Tcl_Alloc(cd->inAllocated);
if (cd->flags & IN_HEADER) {
if (inflateGetHeader(&cd->inStream, &cd->inHeader.header) != Z_OK) {
goto error;
@@ -3667,7 +3677,7 @@ ZlibStackChannelTransform(
goto error;
}
cd->outAllocated = DEFAULT_BUFFER_SIZE;
- cd->outBuffer = ckalloc(cd->outAllocated);
+ cd->outBuffer = Tcl_Alloc(cd->outAllocated);
if (cd->flags & OUT_HEADER) {
if (deflateSetHeader(&cd->outStream, &cd->outHeader.header) != Z_OK) {
goto error;
@@ -3694,17 +3704,17 @@ ZlibStackChannelTransform(
error:
if (cd->inBuffer) {
- ckfree(cd->inBuffer);
+ Tcl_Free(cd->inBuffer);
inflateEnd(&cd->inStream);
}
if (cd->outBuffer) {
- ckfree(cd->outBuffer);
+ Tcl_Free(cd->outBuffer);
deflateEnd(&cd->outStream);
}
if (cd->compDictObj) {
Tcl_DecrRefCount(cd->compDictObj);
}
- ckfree(cd);
+ Tcl_Free(cd);
return NULL;
}
@@ -4018,7 +4028,7 @@ Tcl_ZlibInflate(
Tcl_Interp *interp,
int format,
Tcl_Obj *data,
- int bufferSize,
+ size_t bufferSize,
Tcl_Obj *gzipHeaderDictObj)
{
if (interp) {
@@ -4032,7 +4042,7 @@ unsigned int
Tcl_ZlibCRC32(
unsigned int crc,
const char *buf,
- int len)
+ size_t len)
{
return 0;
}
@@ -4041,7 +4051,7 @@ unsigned int
Tcl_ZlibAdler32(
unsigned int adler,
const char *buf,
- int len)
+ size_t len)
{
return 0;
}