[Libreoffice-commits] core.git: svl/source
Jochen Nitschke
j.nitschke+logerrit at ok.de
Fri Nov 4 08:20:15 UTC 2016
svl/source/filerec/filerec.cxx | 3 +--
svl/source/items/itemset.cxx | 20 ++++++--------------
svl/source/items/poolio.cxx | 3 +--
3 files changed, 8 insertions(+), 18 deletions(-)
New commits:
commit bb3e19624bf4a400e9012b9b4451dc9542261fd8
Author: Jochen Nitschke <j.nitschke+logerrit at ok.de>
Date: Thu Nov 3 09:31:30 2016 +0100
use aggregate initialisation instead of memset for arrays
Change-Id: I084dee370e5c1096e51b8ff4073443c719688469
Reviewed-on: https://gerrit.libreoffice.org/30517
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/svl/source/filerec/filerec.cxx b/svl/source/filerec/filerec.cxx
index b52a935..2086d28 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 d2388c3..524752c 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 4f474ec..d92fc18 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 );
More information about the Libreoffice-commits
mailing list