[sword-cvs] sword/src/modules/common zstr.cpp,1.21,1.22 zverse.cpp,1.31,1.32
sword@www.crosswire.org
sword@www.crosswire.org
Mon, 11 Aug 2003 22:36:33 -0700
Update of /usr/local/cvsroot/sword/src/modules/common
In directory www:/tmp/cvs-serv1419/src/modules/common
Modified Files:
zstr.cpp zverse.cpp
Log Message:
no message
Index: zstr.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/common/zstr.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- zstr.cpp 16 Jul 2003 12:26:09 -0000 1.21
+++ zstr.cpp 12 Aug 2003 05:36:30 -0000 1.22
@@ -422,19 +422,19 @@
start = swordtoarch32(start);
size = swordtoarch32(size);
- *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1);
-
+ SWBuf buf;
+ buf.setSize(size + 5);
lseek(zdtfd->getFd(), start, SEEK_SET);
- read(zdtfd->getFd(), *buf, size);
+ read(zdtfd->getFd(), buf.getRawData(), size);
flushCache();
unsigned long len = size;
+ buf.setSize(size);
+ rawZFilter(buf, 0); // 0 = decipher
- rawZFilter(*buf, len, 0); // 0 = decipher
-
- compressor->zBuf(&len, *buf);
- char * rawBuf = compressor->Buf(0, &len);
+ compressor->zBuf(&len, buf.getRawData());
+ char *rawBuf = compressor->Buf(0, &len);
cacheBlock = new EntriesBlock(rawBuf, len);
cacheBlockIndex = block;
}
@@ -617,9 +617,10 @@
compressor->Buf(rawBuf, &size);
compressor->zBuf(&size);
- char *buf = new char [ size * 2 ];
- memcpy(buf, compressor->zBuf(&size), size); // 1 = encipher
- rawZFilter(buf, size, 1); // 1 = encipher
+ SWBuf buf(size + 5);
+ memcpy(buf.getRawData(), compressor->zBuf(&size), size); // 1 = encipher
+ buf.setSize(size);
+ rawZFilter(buf, 1); // 1 = encipher
long zdxSize = lseek(zdxfd->getFd(), 0, SEEK_END);
long zdtSize = lseek(zdtfd->getFd(), 0, SEEK_END);
Index: zverse.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/common/zverse.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- zverse.cpp 16 Jul 2003 12:26:09 -0000 1.31
+++ zverse.cpp 12 Aug 2003 05:36:30 -0000 1.32
@@ -22,6 +22,7 @@
#include <versekey.h>
#include <zverse.h>
#include <sysdata.h>
+#include <swbuf.h>
#ifndef O_BINARY
@@ -221,17 +222,17 @@
printf ("Error: could not seek to right place in compressed text\n");
return;
}
- pcCompText = new char[ulCompSize];
+ SWBuf pcCompText;
+ pcCompText.setSize(ulCompSize+5);
- if (read(textfp[testmt-1]->getFd(), pcCompText, ulCompSize)<(long)ulCompSize)
- {
+ if (read(textfp[testmt-1]->getFd(), pcCompText.getRawData(), ulCompSize)<(long)ulCompSize) {
printf ("Error reading compressed text\n");
return;
}
-
- rawZFilter(pcCompText, ulCompSize, 0); // 0 = decipher
+ pcCompText.setSize(ulCompSize);
+ rawZFilter(pcCompText, 0); // 0 = decipher
- compressor->zBuf(&ulCompSize, pcCompText);
+ compressor->zBuf(&ulCompSize, pcCompText.getRawData());
if (cacheBuf) {
flushCache();
@@ -245,8 +246,6 @@
cacheTestament = testmt;
cacheBufIdx = ulBuffNum;
- if (pcCompText)
- delete [] pcCompText;
}
}
@@ -342,9 +341,10 @@
compressor->zBuf(&zsize);
outzsize = zsize;
- char *buf = new char [ zsize * 2 ];
- memcpy(buf, compressor->zBuf(&zsize), zsize);
- rawZFilter(buf, zsize, 1); // 1 = encipher
+ SWBuf buf(zsize + 5);
+ memcpy(buf.getRawData(), compressor->zBuf(&zsize), zsize);
+ buf.setSize(zsize);
+ rawZFilter(buf, 1); // 1 = encipher
start = outstart = lseek(textfp[cacheTestament-1]->getFd(), 0, SEEK_END);
@@ -353,8 +353,6 @@
outzsize = archtosword32(zsize);
write(textfp[cacheTestament-1]->getFd(), buf, zsize);
-
- delete [] buf;
lseek(idxfp[cacheTestament-1]->getFd(), idxoff, SEEK_SET);
write(idxfp[cacheTestament-1]->getFd(), &outstart, 4);