Fix intermix of node functors and node delete.
This commit is contained in:
parent
dd564ab321
commit
c794aa02b8
46
functor.cc
46
functor.cc
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: functor.cc,v 1.30 2002/08/12 01:34:59 steve Exp $"
|
#ident "$Id: functor.cc,v 1.31 2002/08/16 05:18:27 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -128,30 +128,31 @@ void Design::functor(functor_t*fun)
|
||||||
|
|
||||||
// apply to nodes
|
// apply to nodes
|
||||||
if (nodes_) {
|
if (nodes_) {
|
||||||
|
assert(nodes_functor_cur_ == 0);
|
||||||
|
assert(nodes_functor_nxt_ == 0);
|
||||||
|
|
||||||
/* Scan the circular list of nodes, starting with the
|
/* Scan the circular list of nodes, starting with the
|
||||||
front of the list. (nodes_ points to the *end* of the
|
front of the list.
|
||||||
list.) The bar is the end point. At the end of the
|
|
||||||
do-while loop, I know that the bar has been
|
This loop interacts with the Design::del_node method
|
||||||
processed or (if bar == 0) no undeleted node has been
|
so that the functor is free to delete any nodes it
|
||||||
processed. */
|
choose. The destructors of the NetNode objects call
|
||||||
NetNode*cur = nodes_->node_next_;
|
the del_node method, which checks with the
|
||||||
NetNode*bar = 0;
|
nodes_functor_* members, to keep the iterator
|
||||||
|
operating safely. */
|
||||||
|
nodes_functor_cur_ = nodes_;
|
||||||
do {
|
do {
|
||||||
NetNode*tmp = cur->node_next_;
|
nodes_functor_nxt_ = nodes_functor_cur_->node_next_;
|
||||||
cur->functor_node(this, fun);
|
nodes_functor_cur_->functor_node(this, fun);
|
||||||
|
|
||||||
/* Detect the case that cur has been deleted by
|
if (nodes_functor_nxt_ == 0)
|
||||||
noticing if tmp->node_prev_ no longer points to
|
break;
|
||||||
cur. If that's the case, clear the bar. */
|
|
||||||
if (tmp->node_prev_ != cur) {
|
nodes_functor_cur_ = nodes_functor_nxt_;
|
||||||
if (cur == bar)
|
} while (nodes_ && (nodes_functor_cur_ != nodes_));
|
||||||
bar = 0;
|
nodes_functor_cur_ = 0;
|
||||||
} else if (bar == 0) {
|
nodes_functor_nxt_ = 0;
|
||||||
bar = cur;
|
|
||||||
}
|
|
||||||
cur = tmp;
|
|
||||||
|
|
||||||
} while (nodes_ && (cur != bar));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -266,6 +267,9 @@ int proc_match_t::event_wait(NetEvWait*)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: functor.cc,v $
|
* $Log: functor.cc,v $
|
||||||
|
* Revision 1.31 2002/08/16 05:18:27 steve
|
||||||
|
* Fix intermix of node functors and node delete.
|
||||||
|
*
|
||||||
* Revision 1.30 2002/08/12 01:34:59 steve
|
* Revision 1.30 2002/08/12 01:34:59 steve
|
||||||
* conditional ident string using autoconfig.
|
* conditional ident string using autoconfig.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: net_design.cc,v 1.26 2002/08/12 01:34:59 steve Exp $"
|
#ident "$Id: net_design.cc,v 1.27 2002/08/16 05:18:27 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -38,6 +38,8 @@ Design:: Design()
|
||||||
{
|
{
|
||||||
procs_idx_ = 0;
|
procs_idx_ = 0;
|
||||||
des_precision_ = 0;
|
des_precision_ = 0;
|
||||||
|
nodes_functor_cur_ = 0;
|
||||||
|
nodes_functor_nxt_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Design::~Design()
|
Design::~Design()
|
||||||
|
|
@ -442,6 +444,19 @@ void Design::add_node(NetNode*net)
|
||||||
void Design::del_node(NetNode*net)
|
void Design::del_node(NetNode*net)
|
||||||
{
|
{
|
||||||
assert(net->design_ == this);
|
assert(net->design_ == this);
|
||||||
|
assert(net != 0);
|
||||||
|
|
||||||
|
/* Interact with the Design::functor method by manipulate the
|
||||||
|
cur and nxt pointers that is is using. */
|
||||||
|
if (net == nodes_functor_nxt_)
|
||||||
|
nodes_functor_nxt_ = nodes_functor_nxt_->node_next_;
|
||||||
|
if (net == nodes_functor_nxt_)
|
||||||
|
nodes_functor_nxt_ = 0;
|
||||||
|
|
||||||
|
if (net == nodes_functor_cur_)
|
||||||
|
nodes_functor_cur_ = 0;
|
||||||
|
|
||||||
|
/* Now perform the actual delete. */
|
||||||
if (nodes_ == net)
|
if (nodes_ == net)
|
||||||
nodes_ = net->node_prev_;
|
nodes_ = net->node_prev_;
|
||||||
|
|
||||||
|
|
@ -485,6 +500,9 @@ void Design::delete_process(NetProcTop*top)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: net_design.cc,v $
|
* $Log: net_design.cc,v $
|
||||||
|
* Revision 1.27 2002/08/16 05:18:27 steve
|
||||||
|
* Fix intermix of node functors and node delete.
|
||||||
|
*
|
||||||
* Revision 1.26 2002/08/12 01:34:59 steve
|
* Revision 1.26 2002/08/12 01:34:59 steve
|
||||||
* conditional ident string using autoconfig.
|
* conditional ident string using autoconfig.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
10
netlist.h
10
netlist.h
|
|
@ -19,7 +19,7 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: netlist.h,v 1.257 2002/08/12 01:35:00 steve Exp $"
|
#ident "$Id: netlist.h,v 1.258 2002/08/16 05:18:27 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -2950,8 +2950,11 @@ class Design {
|
||||||
// tree and per-hop searches for me.
|
// tree and per-hop searches for me.
|
||||||
list<NetScope*>root_scopes_;
|
list<NetScope*>root_scopes_;
|
||||||
|
|
||||||
// List the nodes in the design
|
// List the nodes in the design.
|
||||||
NetNode*nodes_;
|
NetNode*nodes_;
|
||||||
|
// These are in support of the node functor iterator.
|
||||||
|
NetNode*nodes_functor_cur_;
|
||||||
|
NetNode*nodes_functor_nxt_;
|
||||||
|
|
||||||
// List the processes in the design.
|
// List the processes in the design.
|
||||||
NetProcTop*procs_;
|
NetProcTop*procs_;
|
||||||
|
|
@ -3008,6 +3011,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.h,v $
|
* $Log: netlist.h,v $
|
||||||
|
* Revision 1.258 2002/08/16 05:18:27 steve
|
||||||
|
* Fix intermix of node functors and node delete.
|
||||||
|
*
|
||||||
* Revision 1.257 2002/08/12 01:35:00 steve
|
* Revision 1.257 2002/08/12 01:35:00 steve
|
||||||
* conditional ident string using autoconfig.
|
* conditional ident string using autoconfig.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue