X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/673f3b2361e3e78f58c2110cb98017a008af04e3..6270ece7967b322385bbff766ee5f882ba1ef2a2:/examples/msg/kademlia/answer.c diff --git a/examples/msg/kademlia/answer.c b/examples/msg/kademlia/answer.c index 4eb095f620..ee1082bdd8 100644 --- a/examples/msg/kademlia/answer.c +++ b/examples/msg/kademlia/answer.c @@ -1,8 +1,9 @@ -/* Copyright (c) 2012. The SimGrid Team. +/* Copyright (c) 2012-2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "answer.h" XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(msg_kademlia_node); @@ -78,7 +79,13 @@ static int _answer_sort_function(const void *e1, const void *e2) { node_contact_t c1 = *(void **) e1; node_contact_t c2 = *(void **) e2; - return c1->distance >= c2->distance; + if (c1->distance == c2->distance) + return 0; + else + if (c1->distance < c2->distance) + return -1; + else + return 1; } /**