summaryrefslogtreecommitdiff
path: root/sc/source/core/data/compressedarray.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-03 15:56:40 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-06 08:48:46 +0200
commit63d9e2dd97f18ed70b1fd1e8094ff5f74e63f520 (patch)
tree9ba9cc653e2c775e67ff4c140b93a6c28f735ef2 /sc/source/core/data/compressedarray.cxx
parent46780892cd3c49c27fdeb4566b7407602901e98f (diff)
loplugin:useuniqueptr in ScCompressedArray
Change-Id: I6bc46fc209e648e1262ea62e5c13c70a6342ff0d Reviewed-on: https://gerrit.libreoffice.org/58570 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc/source/core/data/compressedarray.cxx')
-rw-r--r--sc/source/core/data/compressedarray.cxx23
1 files changed, 10 insertions, 13 deletions
diff --git a/sc/source/core/data/compressedarray.cxx b/sc/source/core/data/compressedarray.cxx
index 6e8ca59bf5ac..d07de64f5325 100644
--- a/sc/source/core/data/compressedarray.cxx
+++ b/sc/source/core/data/compressedarray.cxx
@@ -39,7 +39,6 @@ ScCompressedArray<A,D>::ScCompressedArray( A nMaxAccessP, const D& rValue )
template< typename A, typename D >
ScCompressedArray<A,D>::~ScCompressedArray()
{
- delete[] pData;
}
template< typename A, typename D >
@@ -48,10 +47,9 @@ void ScCompressedArray<A,D>::Resize( size_t nNewLimit)
if ((nCount <= nNewLimit && nNewLimit < nLimit) || nLimit < nNewLimit)
{
nLimit = nNewLimit;
- DataEntry* pNewData = new DataEntry[nLimit];
- memcpy( pNewData, pData, nCount*sizeof(DataEntry));
- delete[] pData;
- pData = pNewData;
+ std::unique_ptr<DataEntry[]> pNewData(new DataEntry[nLimit]);
+ memcpy( pNewData.get(), pData.get(), nCount*sizeof(DataEntry));
+ pData = std::move(pNewData);
}
}
@@ -104,10 +102,9 @@ void ScCompressedArray<A,D>::SetValue( A nStart, A nEnd, const D& rValue )
nLimit += nScCompressedArrayDelta;
if (nLimit < nNeeded)
nLimit = nNeeded;
- DataEntry* pNewData = new DataEntry[nLimit];
- memcpy( pNewData, pData, nCount*sizeof(DataEntry));
- delete[] pData;
- pData = pNewData;
+ std::unique_ptr<DataEntry[]> pNewData(new DataEntry[nLimit]);
+ memcpy( pNewData.get(), pData.get(), nCount*sizeof(DataEntry));
+ pData = std::move(pNewData);
}
size_t ni; // number of leading entries
@@ -180,7 +177,7 @@ void ScCompressedArray<A,D>::SetValue( A nStart, A nEnd, const D& rValue )
}
if (ni < nj)
{ // remove entries
- memmove( pData + ni, pData + nj,
+ memmove( pData.get() + ni, pData.get() + nj,
(nCount - nj) * sizeof(DataEntry));
nCount -= nj - ni;
}
@@ -191,11 +188,11 @@ void ScCompressedArray<A,D>::SetValue( A nStart, A nEnd, const D& rValue )
if (nInsert <= nCount)
{
if (!bSplit)
- memmove( pData + nInsert + 1, pData + nInsert,
+ memmove( pData.get() + nInsert + 1, pData.get() + nInsert,
(nCount - nInsert) * sizeof(DataEntry));
else
{
- memmove( pData + nInsert + 2, pData + nInsert,
+ memmove( pData.get() + nInsert + 2, pData.get() + nInsert,
(nCount - nInsert) * sizeof(DataEntry));
pData[nInsert+1] = pData[nInsert-1];
nCount++;
@@ -290,7 +287,7 @@ void ScCompressedArray<A,D>::Remove( A nStart, size_t nAccessCount )
}
else
nRemove = 1;
- memmove( pData + nIndex, pData + nIndex + nRemove, (nCount - (nIndex +
+ memmove( pData.get() + nIndex, pData.get() + nIndex + nRemove, (nCount - (nIndex +
nRemove)) * sizeof(DataEntry));
nCount -= nRemove;
}