diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-01-06 19:06:03 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2014-01-06 19:06:21 +0100 |
commit | 6404567b0ad3dab20f39eb93114a30f0b2016f31 (patch) | |
tree | 5612b545b49c2b510de5f939b58685b5c4825644 /writerperfect/source | |
parent | b4ea08def28a510212f4de355b384e8542c014d4 (diff) |
Avoid memcpy completely
Change-Id: I3d27935918930af71f02354696134def6bd052b6
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/common/WPXSvStream.cxx | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/writerperfect/source/common/WPXSvStream.cxx b/writerperfect/source/common/WPXSvStream.cxx index 86e835b0dc23..beaf7025a527 100644 --- a/writerperfect/source/common/WPXSvStream.cxx +++ b/writerperfect/source/common/WPXSvStream.cxx @@ -101,8 +101,6 @@ WPXSvInputStreamImpl::WPXSvInputStreamImpl( Reference< XInputStream > xStream ) WPXSvInputStreamImpl::~WPXSvInputStreamImpl() { - if (mpReadBuffer) - delete [] mpReadBuffer; } const unsigned char *WPXSvInputStreamImpl::read(unsigned long numBytes, unsigned long &numBytesRead) @@ -252,7 +250,6 @@ void WPXSvInputStreamImpl::invalidateReadBuffer() if (mpReadBuffer) { seek((long) tell() + (long)mnReadBufferPos - (long)mnReadBufferLength); - delete [] mpReadBuffer; mpReadBuffer = 0; mnReadBufferPos = 0; mnReadBufferLength = 0; @@ -310,11 +307,10 @@ const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned lon mpImpl->mnReadBufferLength = mpImpl->mnLength - curpos; } else - return mpImpl->read(numBytes, numBytesRead); + mpImpl->mnReadBufferLength = numBytes; - mpImpl->mpReadBuffer = new unsigned char[mpImpl->mnReadBufferLength]; unsigned long tmpNumBytes(0); - const unsigned char *pTmp = mpImpl->read(mpImpl->mnReadBufferLength, tmpNumBytes); + mpImpl->mpReadBuffer = const_cast<unsigned char*>(mpImpl->read(mpImpl->mnReadBufferLength, tmpNumBytes)); if (tmpNumBytes != mpImpl->mnReadBufferLength) mpImpl->mnReadBufferLength = tmpNumBytes; @@ -325,7 +321,6 @@ const unsigned char *WPXSvInputStream::read(unsigned long numBytes, unsigned lon numBytesRead = numBytes; mpImpl->mnReadBufferPos += numBytesRead; - memcpy(mpImpl->mpReadBuffer, pTmp, mpImpl->mnReadBufferLength); return const_cast<const unsigned char *>(mpImpl->mpReadBuffer); } |