Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
rename some symbols around Link::isShared to make their purpose clear
[simgrid.git] / examples / msg / kademlia / answer.c
index 4eb095f..ee1082b 100644 (file)
@@ -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;
 }
 
 /**