diff options
author | Jochen Nitschke <j.nitschke+logerrit@ok.de> | 2016-11-03 09:31:30 +0100 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-11-04 08:19:47 +0000 |
commit | bb3e19624bf4a400e9012b9b4451dc9542261fd8 (patch) | |
tree | bfe25a925fa12a7e2eaf8745f1a614e993d92f46 /svl | |
parent | f4637c07c9ac87c2ad4b687263dfea50b5d4e0ef (diff) |
use aggregate initialisation instead of memset for arrays
Change-Id: I084dee370e5c1096e51b8ff4073443c719688469
Reviewed-on: https://gerrit.libreoffice.org/30517
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/filerec/filerec.cxx | 3 | ||||
-rw-r--r-- | svl/source/items/itemset.cxx | 20 | ||||
-rw-r--r-- | svl/source/items/poolio.cxx | 3 |
3 files changed, 8 insertions, 18 deletions
diff --git a/svl/source/filerec/filerec.cxx b/svl/source/filerec/filerec.cxx index b52a935e462e..2086d2813fc7 100644 --- a/svl/source/filerec/filerec.cxx +++ b/svl/source/filerec/filerec.cxx @@ -497,8 +497,7 @@ bool SfxMultiRecordReader::ReadHeader_Impl() _nContentCount << " claimed, truncating"); _nContentCount = nMaxRecords; } - _pContentOfs = new sal_uInt32[_nContentCount]; - memset(_pContentOfs, 0, _nContentCount*sizeof(sal_uInt32)); + _pContentOfs = new sal_uInt32[_nContentCount]{}; #if defined(OSL_LITENDIAN) _pStream->ReadBytes( _pContentOfs, sizeof(sal_uInt32)*_nContentCount ); #else diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index d2388c3d40d9..524752ccb9a1 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -141,8 +141,7 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool) m_pPool->FillItemIdRanges_Impl( m_pWhichRanges ); const sal_uInt16 nSize = TotalCount(); - m_pItems = new const SfxPoolItem* [ nSize ]; - memset(static_cast<void*>(m_pItems), 0, nSize * sizeof(SfxPoolItem*)); + m_pItems = new const SfxPoolItem*[nSize]{}; } SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2) @@ -157,20 +156,15 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich void SfxItemSet::InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2) { - m_pWhichRanges = new sal_uInt16[ 3 ]; - *(m_pWhichRanges+0) = nWh1; - *(m_pWhichRanges+1) = nWh2; - *(m_pWhichRanges+2) = 0; + m_pWhichRanges = new sal_uInt16[3]{nWh1, nWh2, 0}; const sal_uInt16 nRg = nWh2 - nWh1 + 1; - m_pItems = new const SfxPoolItem* [ nRg ]; - memset(static_cast<void*>(m_pItems), 0, nRg * sizeof(SfxPoolItem*)); + m_pItems = new const SfxPoolItem*[nRg]{}; } void SfxItemSet::InitRanges_Impl(va_list pArgs, sal_uInt16 nWh1, sal_uInt16 nWh2, sal_uInt16 nNull) { sal_uInt16 nSize = InitializeRanges_Impl(m_pWhichRanges, pArgs, nWh1, nWh2, nNull); - m_pItems = new const SfxPoolItem* [ nSize ]; - memset(static_cast<void*>(m_pItems), 0, sizeof(SfxPoolItem*) * nSize); + m_pItems = new const SfxPoolItem*[nSize]{}; } SfxItemSet::SfxItemSet(SfxItemPool& rPool, int nWh1, int nWh2, int nNull, ...) @@ -206,8 +200,7 @@ void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable) pPtr += 2; } - m_pItems = new const SfxPoolItem* [ nCnt ]; - memset(static_cast<void*>(m_pItems), 0, sizeof(SfxPoolItem*) * nCnt); + m_pItems = new const SfxPoolItem*[nCnt]{}; std::ptrdiff_t cnt = pPtr - pWhichPairTable +1; m_pWhichRanges = new sal_uInt16[ cnt ]; @@ -1659,8 +1652,7 @@ SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool ) m_pItems = nullptr; // Allocate nInitCount pairs at USHORTs for Ranges - m_pWhichRanges = new sal_uInt16[ nInitCount + 1 ]; - memset( m_pWhichRanges, 0, (nInitCount + 1) * sizeof(sal_uInt16) ); + m_pWhichRanges = new sal_uInt16[nInitCount + 1]{}; } SfxAllItemSet::SfxAllItemSet(const SfxItemSet &rCopy) diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index 4f474ec787c3..d92fc1891259 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -633,8 +633,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) " max possible entries, but " << nCount << " claimed, truncating"); nCount = nMaxRecords; } - sal_uInt16 *pMap = new sal_uInt16[nCount]; - memset(pMap, 0, nCount * sizeof(sal_uInt16)); + sal_uInt16 *pMap = new sal_uInt16[nCount]{}; for ( sal_uInt16 n = 0; n < nCount; ++n ) rStream.ReadUInt16( pMap[n] ); SetVersionMap( nVersion, nHStart, nHEnd, pMap ); |