diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2022-02-23 07:15:44 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2022-02-23 08:07:21 +0100 |
commit | 8dcda24026d6d803f064351b1a1df8f6b77c2fa0 (patch) | |
tree | 250d956086e0c9c64e74a8dd1040e814ee670e0a | |
parent | 8399c2b37f44cd983381ebf6b9d30ba19ad98f2a (diff) |
Simplify NewCopy a bit; avoid direct use of memcpy
Change-Id: I197978604d0dfa997c95b907715ce891211621f8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130380
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | sal/rtl/strtmpl.hxx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/sal/rtl/strtmpl.hxx b/sal/rtl/strtmpl.hxx index eec7010117d8..856fce560065 100644 --- a/sal/rtl/strtmpl.hxx +++ b/sal/rtl/strtmpl.hxx @@ -1001,18 +1001,17 @@ auto* NewCopy ( IMPL_RTL_STRINGDATA IMPL_RTL_STRINGDATA* pStr, sal_Int32 nCount ) { - assert(nCount >= 0); - IMPL_RTL_STRINGDATA* pData = Alloc<IMPL_RTL_STRINGDATA>( pStr->length ); - OSL_ASSERT(pData != nullptr); - - auto* pDest = pData->buffer; - auto* pSrc = pStr->buffer; + assert(ppThis); + assert(pStr); + assert(nCount >= 0 && nCount <= pStr->length); + *ppThis = Alloc<IMPL_RTL_STRINGDATA>( pStr->length ); + OSL_ASSERT(*ppThis != nullptr); - memcpy( pDest, pSrc, nCount * sizeof(*pSrc) ); + auto* pDest = (*ppThis)->buffer; - *ppThis = pData; + Copy(pDest, pStr->buffer, nCount); - RTL_LOG_STRING_NEW( pData ); + RTL_LOG_STRING_NEW( *ppThis ); return pDest + nCount; } |