Commit 721949b5 authored by Maciej Suminski's avatar Maciej Suminski

Fix memory leak in pns_node and pns_line_placer. Fix coverity uninitialized warnings.

parent 97e4a389
......@@ -385,7 +385,6 @@ void PNS_DP_GATEWAYS::BuildFromPrimitivePair( PNS_DP_PRIMITIVE_PAIR aPair, bool
p0_n = aPair.AnchorN();
shP = aPair.PrimP()->Shape();
}
else if( aPair.PrimP()->OfKind( PNS_ITEM::SEGMENT ) && aPair.PrimN()->OfKind( PNS_ITEM::SEGMENT ) )
{
......@@ -396,6 +395,9 @@ void PNS_DP_GATEWAYS::BuildFromPrimitivePair( PNS_DP_PRIMITIVE_PAIR aPair, bool
majorDirection = ( p0_p - p0_n ).Perpendicular();
if( shP == NULL )
return;
switch( shP->Type() )
{
case SH_RECT:
......
......@@ -42,11 +42,29 @@ using boost::optional;
PNS_DIFF_PAIR_PLACER::PNS_DIFF_PAIR_PLACER( PNS_ROUTER* aRouter ) :
PNS_PLACEMENT_ALGO ( aRouter )
{
m_state = RT_START;
m_chainedPlacement = false;
m_initialDiagonal = false;
m_startDiagonal = false;
m_fitOk = false;
m_netP = 0;
m_netN = 0;
m_iteration = 0;
m_world = NULL;
m_shove = NULL;
m_currentNode = NULL;
m_lastNode = NULL;
m_placingVia = false;
m_viaDiameter = 0;
m_viaDrill = 0;
m_currentWidth = 0;
m_currentNet = 0;
m_currentLayer = 0;
m_startsOnVia = false;
m_orthoMode = false;
m_snapOnTarget = false;
m_currentEndItem = NULL;
m_currentMode = RM_MarkObstacles;
m_idle = true;
}
......
......@@ -28,7 +28,15 @@ PNS_DRAGGER::PNS_DRAGGER( PNS_ROUTER* aRouter ) :
PNS_ALGO_BASE( aRouter )
{
m_world = NULL;
m_lastNode = NULL;
m_mode = SEGMENT;
m_draggedLine = NULL;
m_draggedVia = NULL;
m_shove = NULL;
m_draggedSegmentIndex = 0;
m_dragStatus = false;
m_currentMode = RM_MarkObstacles;
m_initialVia = NULL;
}
......
......@@ -929,7 +929,9 @@ bool PNS_LINE_PLACER::FixRoute( const VECTOR2I& aP, PNS_ITEM* aEndItem )
m_chainedPlacement = !pl.EndsWithVia();
m_splitSeg = false;
initPlacement( );
} else {
}
else
{
m_idle = true;
}
......@@ -955,7 +957,7 @@ void PNS_LINE_PLACER::removeLoops( PNS_NODE* aNode, PNS_LINE* aLatest )
if( a == b )
{
aNode->FindLineEnds( aLatest, a, b);
aNode->FindLineEnds( aLatest, a, b );
}
aNode->FindLinesBetweenJoints( a, b, lines );
......@@ -992,20 +994,23 @@ void PNS_LINE_PLACER::simplifyNewLine( PNS_NODE* aNode, PNS_SEGMENT* aLatest )
if( simplified.PointCount() != l->PointCount() )
{
std::auto_ptr<PNS_LINE> lnew ( l->Clone() );
aNode -> Remove( l );
std::auto_ptr<PNS_LINE> lnew( l->Clone() );
aNode->Remove( l );
lnew->SetShape( simplified );
aNode -> Add( lnew.get() );
aNode->Add( lnew.get() );
}
delete l;
}
void PNS_LINE_PLACER::UpdateSizes( const PNS_SIZES_SETTINGS& aSizes )
{
m_sizes = aSizes;
if( !m_idle )
{
initPlacement ( m_splitSeg );
initPlacement( m_splitSeg );
Move ( m_currentEnd, NULL );
}
}
......@@ -1015,7 +1020,7 @@ void PNS_LINE_PLACER::updateLeadingRatLine()
{
PNS_LINE current = Trace();
SHAPE_LINE_CHAIN ratLine;
PNS_TOPOLOGY topo ( m_lastNode );
PNS_TOPOLOGY topo( m_lastNode );
if( topo.LeadingRatLine( &current, ratLine ) )
Router()->DisplayDebugLine( ratLine, 5, 10000 );
......
......@@ -52,6 +52,7 @@ PNS_NODE::PNS_NODE()
m_root = this;
m_parent = NULL;
m_maxClearance = 800000; // fixme: depends on how thick traces are.
m_clearanceFunctor = NULL;
m_index = new PNS_INDEX;
m_collisionFilter = NULL;
......@@ -179,6 +180,8 @@ struct PNS_NODE::OBSTACLE_VISITOR
int m_extraClearance;
OBSTACLE_VISITOR( PNS_NODE::OBSTACLES& aTab, const PNS_ITEM* aItem, int aKindMask ) :
m_node( NULL ),
m_override( NULL ),
m_tab( aTab ),
m_item( aItem ),
m_kindMask( aKindMask ),
......@@ -517,11 +520,15 @@ void PNS_NODE::addLine( PNS_LINE* aLine, bool aAllowRedundant )
PNS_SEGMENT* pseg = new PNS_SEGMENT( *aLine, s );
PNS_SEGMENT* psegR = NULL;
if ( !aAllowRedundant )
if( !aAllowRedundant )
psegR = findRedundantSegment( pseg );
if( psegR )
{
aLine->LinkSegment( psegR );
delete pseg;
}
else
{
pseg->SetOwner( this );
......
......@@ -119,16 +119,17 @@ bool PNS_COST_ESTIMATOR::IsBetter( PNS_COST_ESTIMATOR& aOther,
* Optimizer
**/
PNS_OPTIMIZER::PNS_OPTIMIZER( PNS_NODE* aWorld ) :
m_world( aWorld ), m_collisionKindMask( PNS_ITEM::ANY ), m_effortLevel( MERGE_SEGMENTS )
m_world( aWorld ),
m_collisionKindMask( PNS_ITEM::ANY ),
m_effortLevel( MERGE_SEGMENTS ),
m_keepPostures( false ),
m_restrictAreaActive( false )
{
// m_cache = new SHAPE_INDEX_LIST<PNS_ITEM*>();
m_restrictAreaActive = false;
}
PNS_OPTIMIZER::~PNS_OPTIMIZER()
{
// delete m_cache;
}
......@@ -188,7 +189,7 @@ void PNS_OPTIMIZER::removeCachedSegments( PNS_LINE* aLine, int aStartVertex, int
PNS_SEGMENT* s = (*segs)[i];
m_cacheTags.erase( s );
m_cache.Remove( s );
} // *cacheRemove( (*segs)[i] );
}
}
......
......@@ -64,6 +64,16 @@ PNS_TOOL_BASE::PNS_TOOL_BASE( const std::string& aToolName ) :
TOOL_INTERACTIVE( aToolName )
{
m_router = NULL;
m_startItem = NULL;
m_startLayer = 0;
m_endItem = NULL;
m_needsSync = false;
m_frame = NULL;
m_ctls = NULL;
m_board = NULL;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment