diff options
author | David Tardon <dtardon@redhat.com> | 2011-05-17 14:19:22 +0200 |
---|---|---|
committer | David Tardon <dtardon@redhat.com> | 2011-05-18 06:05:43 +0200 |
commit | 79901bf9ad29b8037de4550ac9382ffd8ad4cfce (patch) | |
tree | 0c372b8546dab7aaecac04e74a318fe4559fde29 /sfx2/source/view/orgmgr.cxx | |
parent | 8031e734a4f72fe80b17b8b0b5260dcb2d2dd788 (diff) |
do not leak memory
Diffstat (limited to 'sfx2/source/view/orgmgr.cxx')
-rw-r--r-- | sfx2/source/view/orgmgr.cxx | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sfx2/source/view/orgmgr.cxx b/sfx2/source/view/orgmgr.cxx index 5a6c9229d1..58a1b317ea 100644 --- a/sfx2/source/view/orgmgr.cxx +++ b/sfx2/source/view/orgmgr.cxx @@ -491,26 +491,22 @@ sal_Bool SfxOrganizeMgr::Delete(SfxOrganizeListBox_Impl *pCaller, if ( pGroupToDelete ) { sal_uInt16 nItemNum = (sal_uInt16)( pCaller->GetModel()->GetChildCount( pGroupToDelete ) ); - sal_uInt16 nToDeleteNum = 0; - SvLBoxEntry **pEntriesToDelete = new SvLBoxEntry*[nItemNum]; + typedef std::deque<SvLBoxEntry*> BoxEntries; + BoxEntries pEntriesToDelete; sal_uInt16 nInd = 0; for ( nInd = 0; nInd < nItemNum; nInd++ ) - pEntriesToDelete[nInd] = NULL; - - for ( nInd = 0; nInd < nItemNum; nInd++ ) { // TODO/LATER: check that nInd is the same index that is used in pTemplates if ( pTemplates->Delete( nRegion, nInd ) ) { bModified = 1; - pEntriesToDelete[nToDeleteNum++] = pCaller->SvLBox::GetEntry( pGroupToDelete, nInd ); + pEntriesToDelete.push_back( pCaller->SvLBox::GetEntry( pGroupToDelete, nInd ) ); } } - for ( nInd = 0; nInd < nToDeleteNum; nInd++ ) - if ( pEntriesToDelete[nInd] ) - pCaller->GetModel()->Remove( pEntriesToDelete[nInd] ); + for ( BoxEntries::const_iterator aIt( pEntriesToDelete.begin() ), aEnd( pEntriesToDelete.end() ); aIt != aEnd; ++aIt ) + pCaller->GetModel()->Remove( *aIt ); if ( !pCaller->GetModel()->GetChildCount( pGroupToDelete ) ) { |