basic/source/basmgr/basmgr.cxx | 3 ++- basic/source/classes/image.cxx | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
New commits: commit fa357e4a0a44471637373302c4391e6b0c2f1a20 Author: Haokun Wu <hw3...@columbia.edu> AuthorDate: Sat Mar 22 15:42:06 2025 -0400 Commit: Hossein <hoss...@libreoffice.org> CommitDate: Thu Mar 27 01:22:41 2025 +0100 tdf#163691 Replace memcpy with std::copy in basmgr.cxx and image.cxx Change-Id: I19714fd28f0a859586a4699d0ff01673b5e7e42f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/183284 Reviewed-by: Hossein <hoss...@libreoffice.org> Tested-by: Jenkins diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx index 3112021319da..d7f8e39fbe0d 100644 --- a/basic/source/basmgr/basmgr.cxx +++ b/basic/source/basmgr/basmgr.cxx @@ -45,6 +45,7 @@ #include <memory> #include <vector> +#include <algorithm> #define LIB_SEP 0x01 #define LIBINFO_SEP 0x02 @@ -1756,7 +1757,7 @@ static uno::Sequence< sal_Int8 > implGetDialogData( SbxObject* pDialog ) uno::Sequence< sal_Int8 > aData( nLen ); sal_Int8* pDestData = aData.getArray(); const sal_Int8* pSrcData = static_cast<const sal_Int8*>(aMemStream.GetData()); - memcpy( pDestData, pSrcData, nLen ); + std::copy(pSrcData, pSrcData + nLen, pDestData); return aData; } diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx index 95e9a26ae6b2..5b041964678e 100644 --- a/basic/source/classes/image.cxx +++ b/basic/source/classes/image.cxx @@ -229,7 +229,7 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) if (GetToUnicodePoolData(r, nLen, nNext)) { OUString s = read_uInt16s_ToOUString(r, nLen); - memcpy(pStrings.get(), s.getStr(), s.getLength() * sizeof(sal_Unicode)); + std::copy(s.getStr(), s.getStr() + s.getLength(), pStrings.get()); } else { @@ -239,7 +239,7 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion ) { sal_uInt16 nOff2 = static_cast<sal_uInt16>(mvStringOffsets[j]); OUString aStr(pByteStrings.get() + nOff2, strlen(pByteStrings.get() + nOff2), eCharSet); - memcpy(pStrings.get() + nOff2, aStr.getStr(), (aStr.getLength() + 1) * sizeof(sal_Unicode)); + std::copy(aStr.getStr(), aStr.getStr() + aStr.getLength() + 1, pStrings.get() + nOff2); } } } @@ -431,7 +431,7 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer ) { sal_uInt16 nOff = static_cast<sal_uInt16>(mvStringOffsets[ i ]); OString aStr(OUStringToOString(std::u16string_view(pStrings.get() + nOff), eCharSet)); - memcpy( pByteStrings.get() + nOff, aStr.getStr(), (aStr.getLength() + 1) * sizeof( char ) ); + std::copy(aStr.getStr(), aStr.getStr() + aStr.getLength() + 1, pByteStrings.get() + nOff); } r.WriteUInt32( nStringSize ); r.WriteBytes(pByteStrings.get(), nStringSize); @@ -570,7 +570,7 @@ void SbiImage::AddString( const OUString& r ) sal_uInt32 nNewLen = needed + 1024; nNewLen &= 0xFFFFFC00; // trim to 1K border std::unique_ptr<sal_Unicode[]> p(new sal_Unicode[nNewLen]); - memcpy( p.get(), pStrings.get(), nStringSize * sizeof( sal_Unicode ) ); + std::copy(pStrings.get(), pStrings.get() + nStringSize, p.get()); pStrings = std::move(p); nStringSize = sal::static_int_cast< sal_uInt16 >(nNewLen); }