Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


File: sot/source/sdstor/ucbstorage.cxx

Code in question:


BOOL UCBStorage_Impl::Revert()
{
    UCBStorageElement_Impl* pElement = m_aChildrenList.First();
    while ( pElement )
    {
        pElement->m_bIsRemoved = FALSE;
        if ( pElement->m_bIsInserted )
        {
            m_aChildrenList.Remove( pElement );  // correct usage of list ???
        }
        else
        {
            if ( pElement->m_xStream.Is() )
            {
                pElement->m_xStream->m_bCommited = sal_False;
                pElement->m_xStream->Revert();
            }
            else if ( pElement->m_xStorage.Is() )
            {
                pElement->m_xStorage->m_bCommited = sal_False;
                pElement->m_xStorage->Revert();
            }

            pElement->m_aName = pElement->m_aOriginalName;
            pElement->m_bIsRemoved = FALSE;
        }
        pElement = m_aChildrenList.Next();
    }
    return TRUE;
}

This what I'm thinking:
1) The Remove() will delete the current element and basically move the pointer to the next item.
2) The Next() move the pointer to the next item.
3) Thus, if an item is removed we'll skip the next item in the list.

I'm converting this to a vector<> to it's easy to fix:
for ( i = 0, i < size(); ) {
  if () {
        Remove()
  } else {
        ++i
  }
}

Question: Am I reading this correctly?

I need to go to work now; so I'll check back later to see if anyone knows a reason why we should be 
skipping the element after the removed one. If no one complains I'll just fix it tonight after work.

Joe P.

PS: The "correct usage of list???" comment is someone else's.


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.