*/
void answer_add_bucket(bucket_t bucket, answer_t answer)
{
- unsigned int cpt;
- unsigned int id;
- unsigned int 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++;
}
unsigned int i = 0;
unsigned int j = 0;
unsigned int destination = node_list->destination_id;
- node_contact_t node_to_query;
while (j < kademlia_alpha && i < node_list->size) {
/* We need to have at most "kademlia_alpha" requests each time, according to the protocol */
/* Gets the node we want to send the query to */
- node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
+ node_contact_t node_to_query = xbt_dynar_get_as(node_list->nodes, i, node_contact_t);
if (node_to_query->id != node->id) { /* No need to query ourselves */
send_find_node(node, node_to_query->id, destination);
j++;
{
#ifdef XBT_DJB2_HASH_FUNCTION
/* fast implementation of djb2 algorithm */
- int c;
unsigned int hash = 5381;
while (str_len--) {
- c = *str++;
+ int c = *str++;
hash = ((hash << 5) + hash) + c; /* hash * 33 + c */
}
# elif defined(XBT_FNV_HASH_FUNCTION)