X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/417742f1c7f6545db82079acd702fde03547d400..e7d2bc04e18b722f337396b3927ec144e10d7a3c:/examples/msg/dht-kademlia/answer.c diff --git a/examples/msg/dht-kademlia/answer.c b/examples/msg/dht-kademlia/answer.c index 5aa893ff62..6fb5f75de2 100644 --- a/examples/msg/dht-kademlia/answer.c +++ b/examples/msg/dht-kademlia/answer.c @@ -47,12 +47,13 @@ void answer_print(answer_t answer) */ unsigned int answer_merge(answer_t destination, answer_t source) { - node_contact_t contact, contact_copy; + node_contact_t contact; + node_contact_t contact_copy; unsigned int cpt; unsigned int nb_added = 0; /* TODO: Check if same destination */ xbt_dynar_foreach(source->nodes, cpt, contact) { - if (!answer_contains(destination, contact->id)) { + if (answer_contains(destination, contact->id) == 0) { contact_copy = node_contact_copy(contact); xbt_dynar_push(destination->nodes, &contact_copy); destination->size++; @@ -108,14 +109,14 @@ void answer_trim(answer_t answer) */ void answer_add_bucket(bucket_t bucket, answer_t answer) { - unsigned int cpt; - unsigned int id, distance; - node_contact_t contact; xbt_assert((bucket != NULL), "Provided a NULL bucket"); xbt_assert((bucket->nodes != NULL), "Provided a bucket which nodes are NULL"); + + unsigned int cpt; + unsigned int id; xbt_dynar_foreach(bucket->nodes, cpt, id) { - distance = id ^ answer->destination_id; - contact = node_contact_new(id, distance); + unsigned int distance = id ^ answer->destination_id; + node_contact_t contact = node_contact_new(id, distance); xbt_dynar_push(answer->nodes, &contact); answer->size++; } @@ -142,7 +143,7 @@ unsigned int answer_contains(answer_t answer, unsigned int id) */ unsigned int answer_destination_found(answer_t answer) { - if (xbt_dynar_length(answer->nodes) < 1) { + if (xbt_dynar_is_empty(answer->nodes)) { return 0; } node_contact_t contact_tail = xbt_dynar_get_as(answer->nodes, 0, node_contact_t);