tdf#163691 replace memcpy with std::copy_n in package and xmlscript
Restored #include<string.h> header in both files as follow: - /package/source/zippackage/ZipPackageBuffer.cxx - /xmlscript/source/xml_helper/xml_byteseq.cxx Change-Id: I5615140028c9f29eaa87e7269135748790f19ed3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/204441 Tested-by: Julien Nabet <serval2412@yahoo.fr> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
This commit is contained in:
committed by
Julien Nabet
parent
73bbc860d1
commit
1a6bd7b23a
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "XBufferedThreadedStream.hxx"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace css::uno;
|
||||
|
||||
namespace {
|
||||
@@ -147,7 +149,7 @@ sal_Int32 SAL_CALL XBufferedThreadedStream::readBytes( Sequence< sal_Int8 >& rDa
|
||||
}
|
||||
const sal_Int32 limit = std::min<sal_Int32>( nPendingBytes, pBuffer.getLength() - mnOffset );
|
||||
|
||||
memcpy( &pData[i], &pBuffer[mnOffset], limit );
|
||||
std::copy_n(&pBuffer[mnOffset], limit, &pData[i]);
|
||||
|
||||
nPendingBytes -= limit;
|
||||
mnOffset += limit;
|
||||
@@ -173,7 +175,7 @@ sal_Int32 XBufferedThreadedStream::readSomeBytes( sal_Int8* pData, sal_Int32 nBy
|
||||
return nAvailableSize - nPendingBytes;
|
||||
const sal_Int32 limit = std::min<sal_Int32>( nPendingBytes, pBuffer.getLength() - mnOffset );
|
||||
|
||||
memcpy( &pData[i], &pBuffer[mnOffset], limit );
|
||||
std::copy_n(&pBuffer[mnOffset], limit, &pData[i]);
|
||||
|
||||
nPendingBytes -= limit;
|
||||
mnOffset += limit;
|
||||
|
||||
@@ -186,7 +186,8 @@ sal_Int32 SAL_CALL XUnbufferedStream::readBytes( Sequence< sal_Int8 >& aData, sa
|
||||
{
|
||||
sal_Int16 nHeadRead = static_cast< sal_Int16 >(( nRequestedBytes > mnHeaderToRead ?
|
||||
mnHeaderToRead : nRequestedBytes ));
|
||||
memcpy ( aData.getArray(), maHeader.getConstArray() + maHeader.getLength() - mnHeaderToRead, nHeadRead );
|
||||
std::copy_n(maHeader.getConstArray() + maHeader.getLength() - mnHeaderToRead,
|
||||
nHeadRead, aData.getArray());
|
||||
mnHeaderToRead = mnHeaderToRead - nHeadRead;
|
||||
|
||||
if ( nHeadRead < nRequestedBytes )
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <ZipPackageBuffer.hxx>
|
||||
#include <PackageConstants.hxx>
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
#include <sal/log.hxx>
|
||||
|
||||
@@ -50,7 +51,7 @@ sal_Int32 SAL_CALL ZipPackageBuffer::readBytes( Sequence< sal_Int8 >& aData, sal
|
||||
nBytesToRead = static_cast < sal_Int32 > (m_nEnd - m_nCurrent);
|
||||
|
||||
aData.realloc ( nBytesToRead );
|
||||
memcpy(aData.getArray(), m_aBuffer.getConstArray() + m_nCurrent, nBytesToRead);
|
||||
std::copy_n(m_aBuffer.getConstArray() + m_nCurrent, nBytesToRead, aData.getArray());
|
||||
m_nCurrent +=nBytesToRead;
|
||||
return nBytesToRead;
|
||||
}
|
||||
@@ -93,7 +94,8 @@ void SAL_CALL ZipPackageBuffer::writeBytes( const Sequence< sal_Int8 >& aData )
|
||||
m_aBuffer.realloc ( static_cast < sal_Int32 > ( m_nBufferSize ) );
|
||||
m_bMustInitBuffer = false;
|
||||
}
|
||||
memcpy( m_aBuffer.getArray() + m_nCurrent, aData.getConstArray(), static_cast < sal_Int32 > (nDataLen));
|
||||
std::copy_n(aData.getConstArray(), static_cast<sal_Int32>(nDataLen),
|
||||
m_aBuffer.getArray() + m_nCurrent);
|
||||
m_nCurrent+=nDataLen;
|
||||
if (m_nCurrent>m_nEnd)
|
||||
m_nEnd = m_nCurrent;
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include <test/bootstrapfixture.hxx>
|
||||
#include <test/xmltesttools.hxx>
|
||||
#include <unotest/macros_test.hxx>
|
||||
@@ -121,7 +123,7 @@ void XmlScriptTest::exportToFile(std::u16string_view sURL,
|
||||
|
||||
sal_Int32 nPos = bytes.getLength();
|
||||
bytes.realloc(nPos + nRead);
|
||||
memcpy(bytes.getArray() + nPos, readBytes.getConstArray(), static_cast<sal_uInt32>(nRead));
|
||||
std::copy_n(readBytes.getConstArray(), nRead, bytes.getArray() + nPos);
|
||||
}
|
||||
|
||||
osl::File aFile(OUString{ sURL });
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <algorithm>
|
||||
|
||||
#include <cppuhelper/implbase.hxx>
|
||||
#include <xmlscript/xml_helper.hxx>
|
||||
@@ -68,7 +69,7 @@ sal_Int32 BSeqInputStream::readBytes(
|
||||
if (rData.getLength() != nBytesToRead)
|
||||
rData.realloc( nBytesToRead );
|
||||
if (nBytesToRead != 0) {
|
||||
memcpy(rData.getArray(), &_seq[_nPos], nBytesToRead);
|
||||
std::copy_n(_seq.data() + _nPos, nBytesToRead, rData.getArray());
|
||||
}
|
||||
_nPos += nBytesToRead;
|
||||
return nBytesToRead;
|
||||
@@ -142,7 +143,7 @@ Reference< io::XInputStream > createInputStream( const sal_Int8* pData, int len
|
||||
{
|
||||
std::vector<sal_Int8> rInData(len);
|
||||
if (len != 0) {
|
||||
memcpy( rInData.data(), pData, len);
|
||||
std::copy_n(pData, len, rInData.data());
|
||||
}
|
||||
return new BSeqInputStream( std::move(rInData) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user