Bug, In Session::_revalidateTopology(), iterate over an invalid vector!
* Bug: In Anabatic::Session::_revalidateTopology(), when iterating over _segmentInvalidateds, the vector can be modified. If it leads to a reallocation we end up on invalid iterators (using freed memory so sometimes with overwritten contents). Now, iterate with an index which warranty that we get a valid item at each iteration of the loop. And, of course, the vector is ensured to not shrink... * Change: In Anabatic::Session::Session(), reserve (pre-allocate) at least 1024 elements for all vectors. Mostly prevent the above bug and avoid constant reallocation.
This commit is contained in:
parent
3dbaea6aca
commit
477c37643c
|
@ -1515,7 +1515,7 @@ namespace Anabatic {
|
||||||
Edge* edge = neighbor->getWestEdge();
|
Edge* edge = neighbor->getWestEdge();
|
||||||
if (not edge) break;
|
if (not edge) break;
|
||||||
|
|
||||||
if (edge->getReservedCapacity() < maxTermSat)
|
if (edge->getReservedCapacity() < (uint32_t)maxTermSat)
|
||||||
edge->reserveCapacity( maxTermSat - edge->getReservedCapacity() );
|
edge->reserveCapacity( maxTermSat - edge->getReservedCapacity() );
|
||||||
neighbor = neighbor->getWest();
|
neighbor = neighbor->getWest();
|
||||||
}
|
}
|
||||||
|
@ -1524,7 +1524,7 @@ namespace Anabatic {
|
||||||
Edge* edge = neighbor->getEastEdge();
|
Edge* edge = neighbor->getEastEdge();
|
||||||
if (not edge) break;
|
if (not edge) break;
|
||||||
|
|
||||||
if (edge->getReservedCapacity() < maxTermSat)
|
if (edge->getReservedCapacity() < (uint32_t)maxTermSat)
|
||||||
edge->reserveCapacity( maxTermSat - edge->getReservedCapacity() );
|
edge->reserveCapacity( maxTermSat - edge->getReservedCapacity() );
|
||||||
neighbor = neighbor->getEast();
|
neighbor = neighbor->getEast();
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,12 @@ namespace Anabatic {
|
||||||
, _segmentRevalidateds()
|
, _segmentRevalidateds()
|
||||||
, _netInvalidateds ()
|
, _netInvalidateds ()
|
||||||
, _netRevalidateds ()
|
, _netRevalidateds ()
|
||||||
{ }
|
{
|
||||||
|
_autoContacts .reserve( 1024 );
|
||||||
|
_doglegs .reserve( 1024 );
|
||||||
|
_segmentInvalidateds.reserve( 1024 );
|
||||||
|
_segmentRevalidateds.reserve( 1024 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Session::_postCreate ()
|
void Session::_postCreate ()
|
||||||
|
@ -219,7 +224,9 @@ namespace Anabatic {
|
||||||
}
|
}
|
||||||
_canonize ();
|
_canonize ();
|
||||||
|
|
||||||
for ( AutoSegment* segment : _segmentInvalidateds ) {
|
AutoSegment* segment = NULL;
|
||||||
|
for ( size_t i=0 ; i<_segmentInvalidateds.size() ; ++i ) {
|
||||||
|
segment = _segmentInvalidateds[i];
|
||||||
if (segment->isCanonical()) {
|
if (segment->isCanonical()) {
|
||||||
if (segment->isUnsetAxis()) segment->toOptimalAxis();
|
if (segment->isUnsetAxis()) segment->toOptimalAxis();
|
||||||
else segment->toConstraintAxis();
|
else segment->toConstraintAxis();
|
||||||
|
|
Loading…
Reference in New Issue