[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ns] bug?
hi,all:
I think there is a bug in route.cpp. The
function void RouteLogic::check(int n) route.cpp is used the
check whether we have enough storage in the adjacency array to hold a node
numbered "n". If haven't, it will reallocate memory to accomodate the node. All
the content of the original adjacency array will be copied to the
new array. But the source code in route.cpp show that it only copy the cost to
the new array, the entry haven't been copied to the new array. I don't think it
is right.
the following line should be added to the inner for
loop.
adj_[INDEX(i, j, m)].entry =old[INDEX(i, j,
osize)].entry;
void RouteLogic::check(int
n)
{
if (n <
size_)
return;
adj_entry* 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)].cost =old[INDEX(i, j,
osize)].cost;
}
size_ = m;
delete[]
old;
}
HE Jun