tdf#163691 - Use std::copy_n() instead of memcpy()

Change-Id: I5ffd3ea19eda9038620c7a0e07d074ceb928af1b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/192172
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
This commit is contained in:
Sergey Anisimov
2025-10-28 14:34:44 +01:00
committed by Hossein
parent 4adef808cb
commit 629dab07c8
7 changed files with 17 additions and 9 deletions
+2 -1
View File
@@ -24,6 +24,7 @@
#include <tools/long.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <algorithm>
#include <string.h>
#include <memory>
#include <utility>
@@ -74,7 +75,7 @@ struct ExtraPortionInfo
if (pDXArray)
{
pOrgDXArray.reset(new double[nLen]);
memcpy(pOrgDXArray.get(), pDXArray, nLen * sizeof(double));
std::copy_n(pDXArray, nLen, pOrgDXArray.get());
}
else
pOrgDXArray.reset();
+2 -1
View File
@@ -58,6 +58,7 @@
#include <o3tl/deleter.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <algorithm>
#include <functional>
#include <optional>
#include <memory>
@@ -139,7 +140,7 @@ struct ImplIMEInfos
{
nLen = nInputLength;
pAttribs.reset(new ExtTextInputAttr[nInputLength]);
memcpy(pAttribs.get(), pInputAttributes, nInputLength * sizeof(ExtTextInputAttr));
std::copy_n(pInputAttributes, nInputLength, pAttribs.get());
}
void DestroyAttribs()
+2 -2
View File
@@ -171,7 +171,7 @@ void GridWindow::Init(double* pXValues, double* pYValues, int nValues, bool bCut
if (m_pOrigYValues && m_nValues)
{
m_pNewYValues.reset(new double[ m_nValues ]);
memcpy( m_pNewYValues.get(), m_pOrigYValues, sizeof( double ) * m_nValues );
std::copy_n(m_pOrigYValues, m_nValues, m_pNewYValues.get());
}
setBoundings( 0, 0, 1023, 1023 );
@@ -640,7 +640,7 @@ void GridWindow::ChangeMode(ResetType nType)
case ResetType::RESET:
{
if( m_pOrigYValues && m_pNewYValues && m_nValues )
memcpy( m_pNewYValues.get(), m_pOrigYValues, m_nValues*sizeof(double) );
std::copy_n(m_pOrigYValues, m_nValues, m_pNewYValues.get());
}
break;
case ResetType::EXPONENTIAL:
+3 -1
View File
@@ -19,8 +19,10 @@
#pragma once
#include <algorithm>
#include <memory>
#include <stack>
#include <tools/datetime.hxx>
#include <unotools/securityoptions.hxx>
#include <chgtrack.hxx>
@@ -316,7 +318,7 @@ public:
sal_uInt16 GetBufferCount() const
{ return static_cast< sal_uInt16 >( (pLast - pBuffer.get()) + 1 ); }
void GetBufferCopy( sal_uInt16* pDest ) const
{ memcpy( pDest, pBuffer.get(), sizeof(sal_uInt16) * GetBufferCount() ); }
{ std::copy_n( pBuffer.get(), GetBufferCount(), pDest ); }
};
// XclExpChTrTabId - tab id record
+2 -1
View File
@@ -21,6 +21,7 @@
#include <sal/log.hxx>
#include <osl/diagnose.h>
#include <algorithm>
#include <cstddef>
#include <utility>
@@ -293,7 +294,7 @@ void TEIMEInfos::CopyAttribs(const ExtTextInputAttr* pA, sal_Int32 nL)
{
nLen = nL;
pAttribs.reset( new ExtTextInputAttr[ nL ] );
memcpy( pAttribs.get(), pA, nL*sizeof(ExtTextInputAttr) );
std::copy_n(pA, nL, pAttribs.get());
}
void TEIMEInfos::DestroyAttribs()
+3 -2
View File
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <algorithm>
#include <string.h>
#include <utility>
@@ -30,7 +31,7 @@ CommandExtTextInputData::CommandExtTextInputData( OUString aText,
if ( pTextAttr && !maText.isEmpty() )
{
mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
memcpy( mpTextAttr.get(), pTextAttr, maText.getLength()*sizeof(ExtTextInputAttr) );
std::copy_n(pTextAttr, maText.getLength(), mpTextAttr.get());
}
mnCursorPos = nCursorPos;
@@ -44,7 +45,7 @@ CommandExtTextInputData::CommandExtTextInputData( const CommandExtTextInputData&
if ( rData.mpTextAttr && !maText.isEmpty() )
{
mpTextAttr.reset( new ExtTextInputAttr[maText.getLength()] );
memcpy( mpTextAttr.get(), rData.mpTextAttr.get(), maText.getLength()*sizeof(ExtTextInputAttr) );
std::copy_n(rData.mpTextAttr.get(), maText.getLength(), mpTextAttr.get());
}
mnCursorPos = rData.mnCursorPos;
+3 -1
View File
@@ -62,6 +62,8 @@
#include <com/sun/star/datatransfer/dnd/XDragSource.hpp>
#include <com/sun/star/awt/MouseEvent.hpp>
#include <algorithm>
#define IMPL_MIN_NEEDSYSWIN 49
namespace
@@ -1444,7 +1446,7 @@ static bool ImplHandleExtTextInput( vcl::Window* pWindow,
if ( pTextAttr )
{
pWinData->mpExtOldAttrAry.reset( new ExtTextInputAttr[rText.getLength()] );
memcpy( pWinData->mpExtOldAttrAry.get(), pTextAttr, rText.getLength()*sizeof( ExtTextInputAttr ) );
std::copy_n(pTextAttr, rText.getLength(), pWinData->mpExtOldAttrAry.get());
}
return !ImplCallCommand( pChild, CommandEventId::ExtTextInput, &aData );
}