<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
On 01/04/2013 19:15, Markus Mohrhard wrote:
<blockquote
cite="mid:CAEDdEt4+6_7isWUaAmWHdU5bskNJPTRqSWcyPsH+QrgBfN_W4A@mail.gmail.com"
type="cite">
<div dir="ltr">Hey julien,<br>
<div>
<div class="gmail_extra">There are a lot of iterators stuff in<br>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
core/basegfx/source/polygon/b3dpolygon.cxx, I tried to
fix 'prefix ++/--<br>
operators for non-primitive types' errors (provided by
cppcheck) but I saw<br>
several iterator things I'm not sure, eg:<br>
...<br>
Isn't aEnd invalidated by push_back call?<br>
</blockquote>
<br>
<div><br>
</div>
<div>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.<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
Ok (I'll try to remember this)<br>
<blockquote
cite="mid:CAEDdEt4+6_7isWUaAmWHdU5bskNJPTRqSWcyPsH+QrgBfN_W4A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>
</div>
<div><br>
<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
Isn't aEnd += nCount dangerous? (if aEnd tries to go
further than<br>
rOriginal.maVector.end())<br>
</blockquote>
<div><br>
</div>
<div>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.<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
Done, see
<a class="moz-txt-link-freetext" href="http://cgit.freedesktop.org/libreoffice/core/commit/?id=9b40d14eb91573e62bdd8a6b9157f623a8c4cf7f">http://cgit.freedesktop.org/libreoffice/core/commit/?id=9b40d14eb91573e62bdd8a6b9157f623a8c4cf7f</a><br>
<blockquote
cite="mid:CAEDdEt4+6_7isWUaAmWHdU5bskNJPTRqSWcyPsH+QrgBfN_W4A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
....<br>
<br>
Isn't aEnd iterator invalidated by insert call?<br>
</blockquote>
<div><br>
</div>
<div>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.<br>
</div>
</div>
</div>
</div>
</div>
</blockquote>
You're right (as always! :-)), I should have noticed this.<br>
<blockquote
cite="mid:CAEDdEt4+6_7isWUaAmWHdU5bskNJPTRqSWcyPsH+QrgBfN_W4A@mail.gmail.com"
type="cite">
<div dir="ltr">
<div>
<div class="gmail_extra">
<div class="gmail_quote">
<div>
<br>
</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
There are others in this file but again, I'm not sure,
I'm just wondering.<br>
</blockquote>
</div>
<br>
</div>
<div class="gmail_extra">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.<br>
</div>
</div>
</div>
</blockquote>
Thank you Markus for your detailed answer and your patience.<br>
<br>
Regards,<br>
<br>
Julien<br>
</body>
</html>