mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 695843 part 4 - Allow nsZipCursor to always use the given buffer. r=tglek
This commit is contained in:
parent
911ad54a40
commit
b28c6a9643
@ -1038,7 +1038,7 @@ nsZipCursor::~nsZipCursor()
|
||||
}
|
||||
}
|
||||
|
||||
PRUint8* nsZipCursor::Read(PRUint32 *aBytesRead) {
|
||||
PRUint8* nsZipCursor::ReadOrCopy(PRUint32 *aBytesRead, bool aCopy) {
|
||||
int zerr;
|
||||
PRUint8 *buf = nsnull;
|
||||
bool verifyCRC = true;
|
||||
@ -1048,10 +1048,17 @@ PRUint8* nsZipCursor::Read(PRUint32 *aBytesRead) {
|
||||
MOZ_WIN_MEM_TRY_BEGIN
|
||||
switch (mItem->Compression()) {
|
||||
case STORED:
|
||||
if (!aCopy) {
|
||||
*aBytesRead = mZs.avail_in;
|
||||
buf = mZs.next_in;
|
||||
mZs.next_in += mZs.avail_in;
|
||||
mZs.avail_in = 0;
|
||||
} else {
|
||||
*aBytesRead = mZs.avail_in > mBufSize ? mBufSize : mZs.avail_in;
|
||||
memcpy(mBuf, mZs.next_in, *aBytesRead);
|
||||
mZs.avail_in -= *aBytesRead;
|
||||
mZs.next_in += *aBytesRead;
|
||||
}
|
||||
break;
|
||||
case DEFLATED:
|
||||
buf = mBuf;
|
||||
|
@ -310,9 +310,24 @@ public:
|
||||
* @param aBytesRead Outparam for number of bytes read.
|
||||
* @return data read or NULL if item is corrupted.
|
||||
*/
|
||||
PRUint8* Read(PRUint32 *aBytesRead);
|
||||
PRUint8* Read(PRUint32 *aBytesRead) {
|
||||
return ReadOrCopy(aBytesRead, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a copy. It always uses aBuf(passed in constructor).
|
||||
*
|
||||
* @param aBytesRead Outparam for number of bytes read.
|
||||
* @return data read or NULL if item is corrupted.
|
||||
*/
|
||||
PRUint8* Copy(PRUint32 *aBytesRead) {
|
||||
return ReadOrCopy(aBytesRead, true);
|
||||
}
|
||||
|
||||
private:
|
||||
/* Actual implementation for both Read and Copy above */
|
||||
PRUint8* ReadOrCopy(PRUint32 *aBytesRead, bool aCopy);
|
||||
|
||||
nsZipItem *mItem;
|
||||
PRUint8 *mBuf;
|
||||
PRUint32 mBufSize;
|
||||
|
Loading…
Reference in New Issue
Block a user