[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RouteLogic



Hi,

I would like to know why route.cc> RouteLogic::reset() does not 
perform the same check as RouteLogic::insert().

RouteLogic::check() is extending size_ ;  I think reset()
should call the same function, otherwise there is a bug when 
several link DOWN are reset in adj_[INDEX(src, dst, size_)].
Size should be extended before if necessary.
 

Strange behavior: I have 

	route.cc:471: failed assertion `dst < size_'

when I have nodes with index y, y+1, y+2, y+3
connected with nodes index x, x+1, x+2, x+3 with a
dynamic "DOWN" link, but it works fine in some different order...





Thierry.

-------------------------------------------------------------------



void RouteLogic::check(int n)
{
        if (n < size_)
                return;
 
        int* old = adj_;
        int osize = size_;
        int m = osize;
        if (m == 0)
                m = 16;
        while (m <= n)
                m <<= 1;
 
        alloc(m);
        for (int i = 0; i < osize; ++i) {
                for (int j = 0; j < osize; ++j)
                        adj_[INDEX(i, j, m)] = old[INDEX(i, j, osize)];
        }
        size_ = m;
        delete[] old;
}

void RouteLogic::insert(int src, int dst, int cost)
{
        check(src);
        check(dst);
        adj_[INDEX(src, dst, size_)] = cost;
}
 
void RouteLogic::reset(int src, int dst)
{
        assert(src < size_);
        assert(dst < size_);
        adj_[INDEX(src, dst, size_)] = INFINITY;