Commit 0d250f92 authored by Juliusz Chroboczek's avatar Juliusz Chroboczek

Use id[0] = 0xFF for marking unused neighbour entries.

parent d9aa2928
...@@ -47,8 +47,8 @@ flush_neighbour(struct neighbour *neigh) ...@@ -47,8 +47,8 @@ flush_neighbour(struct neighbour *neigh)
numneighs--; numneighs--;
VALGRIND_MAKE_MEM_UNDEFINED(neigh, sizeof(*neigh)); VALGRIND_MAKE_MEM_UNDEFINED(neigh, sizeof(*neigh));
} else { } else {
/* The first byte is used to mark unused entries */ VALGRIND_MAKE_MEM_UNDEFINED(neigh, sizeof(*neigh));
VALGRIND_MAKE_MEM_UNDEFINED((char*)neigh + 1, sizeof(*neigh) - 1); neigh->id[0] = 0xFF;
} }
} }
...@@ -57,7 +57,7 @@ find_neighbour(const unsigned char *address, struct network *net) ...@@ -57,7 +57,7 @@ find_neighbour(const unsigned char *address, struct network *net)
{ {
int i; int i;
for(i = 0; i < numneighs; i++) { for(i = 0; i < numneighs; i++) {
if(neighs[i].id[0] == 0) if(neighs[i].id[0] == 0xFF)
continue; continue;
if(memcmp(address, neighs[i].address, 16) == 0 && if(memcmp(address, neighs[i].address, 16) == 0 &&
neighs[i].network == net) neighs[i].network == net)
...@@ -87,7 +87,7 @@ add_neighbour(const unsigned char *id, const unsigned char *address, ...@@ -87,7 +87,7 @@ add_neighbour(const unsigned char *id, const unsigned char *address,
debugf("Creating neighbour %s (%s).\n", debugf("Creating neighbour %s (%s).\n",
format_address(id), format_address(address)); format_address(id), format_address(address));
for(i = 0; i < numneighs; i++) { for(i = 0; i < numneighs; i++) {
if(neighs[i].id[0] == 0) if(neighs[i].id[0] == 0xFF)
neigh = &neighs[i]; neigh = &neighs[i];
} }
if(!neigh) { if(!neigh) {
......
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