Kaydet (Commit) bb3e1962 authored tarafından Jochen Nitschke's avatar Jochen Nitschke Kaydeden (comit) Noel Grandin

use aggregate initialisation instead of memset for arrays

Change-Id: I084dee370e5c1096e51b8ff4073443c719688469
Reviewed-on: https://gerrit.libreoffice.org/30517Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst f4637c07
...@@ -497,8 +497,7 @@ bool SfxMultiRecordReader::ReadHeader_Impl() ...@@ -497,8 +497,7 @@ bool SfxMultiRecordReader::ReadHeader_Impl()
_nContentCount << " claimed, truncating"); _nContentCount << " claimed, truncating");
_nContentCount = nMaxRecords; _nContentCount = nMaxRecords;
} }
_pContentOfs = new sal_uInt32[_nContentCount]; _pContentOfs = new sal_uInt32[_nContentCount]{};
memset(_pContentOfs, 0, _nContentCount*sizeof(sal_uInt32));
#if defined(OSL_LITENDIAN) #if defined(OSL_LITENDIAN)
_pStream->ReadBytes( _pContentOfs, sizeof(sal_uInt32)*_nContentCount ); _pStream->ReadBytes( _pContentOfs, sizeof(sal_uInt32)*_nContentCount );
#else #else
......
...@@ -141,8 +141,7 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool) ...@@ -141,8 +141,7 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool)
m_pPool->FillItemIdRanges_Impl( m_pWhichRanges ); m_pPool->FillItemIdRanges_Impl( m_pWhichRanges );
const sal_uInt16 nSize = TotalCount(); const sal_uInt16 nSize = TotalCount();
m_pItems = new const SfxPoolItem* [ nSize ]; m_pItems = new const SfxPoolItem*[nSize]{};
memset(static_cast<void*>(m_pItems), 0, nSize * sizeof(SfxPoolItem*));
} }
SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2) SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2)
...@@ -157,20 +156,15 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich ...@@ -157,20 +156,15 @@ SfxItemSet::SfxItemSet(SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich
void SfxItemSet::InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2) void SfxItemSet::InitRanges_Impl(sal_uInt16 nWh1, sal_uInt16 nWh2)
{ {
m_pWhichRanges = new sal_uInt16[ 3 ]; m_pWhichRanges = new sal_uInt16[3]{nWh1, nWh2, 0};
*(m_pWhichRanges+0) = nWh1;
*(m_pWhichRanges+1) = nWh2;
*(m_pWhichRanges+2) = 0;
const sal_uInt16 nRg = nWh2 - nWh1 + 1; const sal_uInt16 nRg = nWh2 - nWh1 + 1;
m_pItems = new const SfxPoolItem* [ nRg ]; m_pItems = new const SfxPoolItem*[nRg]{};
memset(static_cast<void*>(m_pItems), 0, nRg * sizeof(SfxPoolItem*));
} }
void SfxItemSet::InitRanges_Impl(va_list pArgs, sal_uInt16 nWh1, sal_uInt16 nWh2, sal_uInt16 nNull) 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); sal_uInt16 nSize = InitializeRanges_Impl(m_pWhichRanges, pArgs, nWh1, nWh2, nNull);
m_pItems = new const SfxPoolItem* [ nSize ]; m_pItems = new const SfxPoolItem*[nSize]{};
memset(static_cast<void*>(m_pItems), 0, sizeof(SfxPoolItem*) * nSize);
} }
SfxItemSet::SfxItemSet(SfxItemPool& rPool, int nWh1, int nWh2, int nNull, ...) SfxItemSet::SfxItemSet(SfxItemPool& rPool, int nWh1, int nWh2, int nNull, ...)
...@@ -206,8 +200,7 @@ void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable) ...@@ -206,8 +200,7 @@ void SfxItemSet::InitRanges_Impl(const sal_uInt16 *pWhichPairTable)
pPtr += 2; pPtr += 2;
} }
m_pItems = new const SfxPoolItem* [ nCnt ]; m_pItems = new const SfxPoolItem*[nCnt]{};
memset(static_cast<void*>(m_pItems), 0, sizeof(SfxPoolItem*) * nCnt);
std::ptrdiff_t cnt = pPtr - pWhichPairTable +1; std::ptrdiff_t cnt = pPtr - pWhichPairTable +1;
m_pWhichRanges = new sal_uInt16[ cnt ]; m_pWhichRanges = new sal_uInt16[ cnt ];
...@@ -1659,8 +1652,7 @@ SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool ) ...@@ -1659,8 +1652,7 @@ SfxAllItemSet::SfxAllItemSet( SfxItemPool &rPool )
m_pItems = nullptr; m_pItems = nullptr;
// Allocate nInitCount pairs at USHORTs for Ranges // Allocate nInitCount pairs at USHORTs for Ranges
m_pWhichRanges = new sal_uInt16[ nInitCount + 1 ]; m_pWhichRanges = new sal_uInt16[nInitCount + 1]{};
memset( m_pWhichRanges, 0, (nInitCount + 1) * sizeof(sal_uInt16) );
} }
SfxAllItemSet::SfxAllItemSet(const SfxItemSet &rCopy) SfxAllItemSet::SfxAllItemSet(const SfxItemSet &rCopy)
......
...@@ -633,8 +633,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) ...@@ -633,8 +633,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream)
" max possible entries, but " << nCount << " claimed, truncating"); " max possible entries, but " << nCount << " claimed, truncating");
nCount = nMaxRecords; nCount = nMaxRecords;
} }
sal_uInt16 *pMap = new sal_uInt16[nCount]; sal_uInt16 *pMap = new sal_uInt16[nCount]{};
memset(pMap, 0, nCount * sizeof(sal_uInt16));
for ( sal_uInt16 n = 0; n < nCount; ++n ) for ( sal_uInt16 n = 0; n < nCount; ++n )
rStream.ReadUInt16( pMap[n] ); rStream.ReadUInt16( pMap[n] );
SetVersionMap( nVersion, nHStart, nHEnd, pMap ); SetVersionMap( nVersion, nHStart, nHEnd, pMap );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment