A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
plug a memleak
[simgrid.git]
/
examples
/
msg
/
dht-kademlia
/
node.c
diff --git
a/examples/msg/dht-kademlia/node.c
b/examples/msg/dht-kademlia/node.c
index
99ee294
..
c0741d6
100644
(file)
--- a/
examples/msg/dht-kademlia/node.c
+++ b/
examples/msg/dht-kademlia/node.c
@@
-115,20
+115,20
@@
unsigned int get_id_in_prefix(unsigned int id, unsigned int prefix)
{
if (prefix == 0) {
return 0;
+ } else {
+ return (1U << ((unsigned int)(prefix - 1))) ^ id;
}
- unsigned int n = 1 << (prefix - 1);
- return n ^ id;
}
/** @brief Returns the prefix of an identifier.
* The prefix is the id of the bucket in which the remote identifier xor our identifier should be stored.
- * @param id : bigunsigned int id to test
+ * @param id : big
unsigned int id to test
* @param nb_bits : key size
*/
unsigned int get_node_prefix(unsigned int id, unsigned int nb_bits)
{
- unsigned int
j,
size = sizeof(unsigned int) * 8;
- for (j = 0; j < size; j++) {
+ unsigned int size = sizeof(unsigned int) * 8;
+ for (
unsigned int
j = 0; j < size; j++) {
if (((id >> (size - 1 - j)) & 0x1) != 0) {
return nb_bits - (j);
}