Kaydet (Commit) a064fb20 authored tarafından Noel Grandin's avatar Noel Grandin

use unique_ptr in RemoveWhichRange

Change-Id: I6c0f07f0dc4a7f6bfa15c0ea720f349894559429
Reviewed-on: https://gerrit.libreoffice.org/65340
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 6774e3ce
...@@ -103,7 +103,7 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl ...@@ -103,7 +103,7 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl
/** /**
* @returns a new WhichTable, which we need to squash at some point with a delete * @returns a new WhichTable, which we need to squash at some point with a delete
*/ */
sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd); std::unique_ptr<sal_uInt16[]> RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd);
/** /**
* Helper class for the communication between the dialog * Helper class for the communication between the dialog
......
...@@ -2129,9 +2129,9 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll) ...@@ -2129,9 +2129,9 @@ bool SdrObjEditView::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll)
// Otherwise split Set, if necessary. // Otherwise split Set, if necessary.
// Now we build an ItemSet aSet that doesn't contain EE_Items from // Now we build an ItemSet aSet that doesn't contain EE_Items from
// *pSet (otherwise it would be a copy). // *pSet (otherwise it would be a copy).
sal_uInt16* pNewWhichTable=RemoveWhichRange(pSet->GetRanges(),EE_ITEMS_START,EE_ITEMS_END); std::unique_ptr<sal_uInt16[]> pNewWhichTable=RemoveWhichRange(pSet->GetRanges(),EE_ITEMS_START,EE_ITEMS_END);
SfxItemSet aSet(mpModel->GetItemPool(),pNewWhichTable); SfxItemSet aSet(mpModel->GetItemPool(),pNewWhichTable.get());
delete[] pNewWhichTable; pNewWhichTable.reset();
SfxWhichIter aIter(aSet); SfxWhichIter aIter(aSet);
sal_uInt16 nWhich=aIter.FirstWhich(); sal_uInt16 nWhich=aIter.FirstWhich();
while (nWhich!=0) while (nWhich!=0)
......
...@@ -377,7 +377,7 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl ...@@ -377,7 +377,7 @@ bool SearchOutlinerItems(const SfxItemSet& rSet, bool bInklDefaults, bool* pbOnl
return bHas; return bHas;
} }
sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd) std::unique_ptr<sal_uInt16[]> RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRangeBeg, sal_uInt16 nRangeEnd)
{ {
// Six possible cases (per range): // Six possible cases (per range):
// [Beg..End] Range, to delete // [Beg..End] Range, to delete
...@@ -403,8 +403,8 @@ sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRange ...@@ -403,8 +403,8 @@ sal_uInt16* RemoveWhichRange(const sal_uInt16* pOldWhichTable, sal_uInt16 nRange
else /* nCase=6 */ nAlloc+=2; else /* nCase=6 */ nAlloc+=2;
} }
sal_uInt16* pNewWhichTable=new sal_uInt16[nAlloc]; std::unique_ptr<sal_uInt16[]> pNewWhichTable(new sal_uInt16[nAlloc]);
memcpy(pNewWhichTable,pOldWhichTable,nAlloc*sizeof(sal_uInt16)); memcpy(pNewWhichTable.get(), pOldWhichTable, nAlloc*sizeof(sal_uInt16));
pNewWhichTable[nAlloc-1]=0; // in case 3, there's no 0 at the end. pNewWhichTable[nAlloc-1]=0; // in case 3, there's no 0 at the end.
// now remove the unwanted ranges // now remove the unwanted ranges
nNum=nAlloc-1; nNum=nAlloc-1;
......
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