diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-07-18 11:28:34 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-07-18 13:09:51 +0200 |
commit | fd2e907e448991e5c8b54acbe7e31bff24c8e875 (patch) | |
tree | fb5fcca1568589e4f430259ae3f451bf7eaf148b /comphelper | |
parent | aaebfb9baf53e4ed221a9bb8e1772fcbb7b921ab (diff) |
comphelper::ByteWriter::writeSomeBytes always writes all bytes
...so rename it to writeBytes for clarity, and drop the redundant return value.
Also clarify that it has a narrow interface and requires nBytesToWrite to be
non-negative.
Change-Id: I76dee83fecd6350f473f55dcffb950c16aa22d93
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137169
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'comphelper')
-rw-r--r-- | comphelper/source/misc/storagehelper.cxx | 2 | ||||
-rw-r--r-- | comphelper/source/streaming/memorystream.cxx | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/comphelper/source/misc/storagehelper.cxx b/comphelper/source/misc/storagehelper.cxx index 5f8527bcf273..934261b0c500 100644 --- a/comphelper/source/misc/storagehelper.cxx +++ b/comphelper/source/misc/storagehelper.cxx @@ -194,7 +194,7 @@ void OStorageHelper::CopyInputToOutput( do { nRead = pByteReader->readSomeBytes ( aTempBuf, nConstBufferSize ); - pByteWriter->writeSomeBytes ( aTempBuf, nRead ); + pByteWriter->writeBytes ( aTempBuf, nRead ); } while ( nRead == nConstBufferSize ); } diff --git a/comphelper/source/streaming/memorystream.cxx b/comphelper/source/streaming/memorystream.cxx index 8bf3c3e90f5c..58380eb60d1e 100644 --- a/comphelper/source/streaming/memorystream.cxx +++ b/comphelper/source/streaming/memorystream.cxx @@ -18,6 +18,7 @@ */ #include <algorithm> +#include <cassert> #include <memory> #include <boost/core/noinit_adaptor.hpp> @@ -93,7 +94,7 @@ public: virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& aIdentifier ) override; // comphelper::ByteWriter - virtual sal_Int32 writeSomeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override; + virtual void writeBytes(const sal_Int8* aData, sal_Int32 nBytesToWrite) override; private: std::vector< sal_Int8, boost::noinit_adaptor<std::allocator<sal_Int8>> > maData; @@ -226,10 +227,11 @@ void SAL_CALL UNOMemoryStream::writeBytes( const Sequence< sal_Int8 >& aData ) mnCursor += nBytesToWrite; } -sal_Int32 UNOMemoryStream::writeSomeBytes( const sal_Int8* pInData, sal_Int32 nBytesToWrite ) +void UNOMemoryStream::writeBytes( const sal_Int8* pInData, sal_Int32 nBytesToWrite ) { + assert(nBytesToWrite >= 0); if( !nBytesToWrite ) - return 0; + return; sal_Int64 nNewSize = static_cast<sal_Int64>(mnCursor) + nBytesToWrite; if( nNewSize > SAL_MAX_INT32 ) @@ -247,7 +249,6 @@ sal_Int32 UNOMemoryStream::writeSomeBytes( const sal_Int8* pInData, sal_Int32 nB memcpy(pCursor, pInData, nBytesToWrite); mnCursor += nBytesToWrite; - return nBytesToWrite; } void SAL_CALL UNOMemoryStream::flush() |