On 01/04/2013 19:15, Markus Mohrhard wrote:
Hey julien,
There are a lot of iterators stuff in

    core/basegfx/source/polygon/b3dpolygon.cxx, I tried to fix 'prefix
    ++/--
    operators for non-primitive types' errors (provided by cppcheck)
    but I saw
    several iterator things I'm not sure, eg:
    ...
    Isn't aEnd invalidated by push_back call?



No. Push_back only invalidates if it has to reallocate the memory for the elements which does not happen if you make sure that enough space is reserved. Additionally we have two different vectors here and therefore we have no invalidation in any case.
Ok (I'll try to remember this)


    Isn't aEnd += nCount dangerous? (if aEnd tries to go further than
    rOriginal.maVector.end())


It very much depends on what nCount is. If nCount is always <= rOriginal.maVector.size then this call is perfectly safe. I would add an assert statement into this method to make sure that the assumption is always true.
Done, see http://cgit.freedesktop.org/libreoffice/core/commit/?id=9b40d14eb91573e62bdd8a6b9157f623a8c4cf7f


    ....

    Isn't aEnd iterator invalidated by insert call?


No. Notice that there are two different vectors involved. rSource.maVector which provides aStart and aEnd is not changed. This is just the range version of the the insert method that insert all elements between aStart and aEnd into maVector.
You're right (as always! :-)), I should have noticed this.


    There are others in this file but again, I'm not sure, I'm just
    wondering.


Except for the case with nCount which depends on the context these cases are correct. The way forward is to add an assert statement to make sure that this assumption is true and check all the callers.
Thank you Markus for your detailed answer and your patience.

Regards,

Julien
_______________________________________________
LibreOffice mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to