max_nodes, net_nodes

Felix Salfelder <[email protected]>
Newsgroups gmane.comp.gnu.gnucap.devel
Message-ID <[email protected]>
Hi Al.

in COMPONENT::set_port_by_name, there is a call to port_name(i) in

for (int i=0; i<max_nodes(); ++i) {
[..]
}

and then

std::string DEV_SUBCKT::port_name(int i)const {
  if (_parent) {
    return _parent->port_value(i);
  }else{itested();
    return "";
  }
}

here, _parent is a MODEL_SUBCKT where port_value comes from COMPONENT, but...

const std::string COMPONENT::port_value(int i)const
{
  assert(_n);
  assert(i >= 0);
  assert(i < net_nodes()); // <- boom
  return _n[i].short_label();
}

now, this looks reasonable...

- change max_nodes() in DEV_SUBCKT to
  {if(_parent){ return _parent->net_nodes();}else{return PORTS_PER_SUBCKT;}}
- change the asertion in COMPONENT::port_value(int) to
  assert(i < max_nodes());

do you agree? anything else maybe?

thanks
felix
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.