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
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.