aboutsummaryrefslogtreecommitdiff
path: root/src/secretsharing/gnunet-service-secretsharing.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/secretsharing/gnunet-service-secretsharing.c')
-rw-r--r--src/secretsharing/gnunet-service-secretsharing.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/secretsharing/gnunet-service-secretsharing.c b/src/secretsharing/gnunet-service-secretsharing.c
index 0a22561cd..a0e440084 100644
--- a/src/secretsharing/gnunet-service-secretsharing.c
+++ b/src/secretsharing/gnunet-service-secretsharing.c
@@ -409,7 +409,9 @@ time_between (struct GNUNET_TIME_Absolute start,
409static int 409static int
410peer_id_cmp (const void *p1, const void *p2) 410peer_id_cmp (const void *p1, const void *p2)
411{ 411{
412 return memcmp (p1, p2, sizeof (struct GNUNET_PeerIdentity)); 412 return memcmp (p1,
413 p2,
414 sizeof (struct GNUNET_PeerIdentity));
413} 415}
414 416
415 417
@@ -427,8 +429,11 @@ peer_find (const struct GNUNET_PeerIdentity *haystack, unsigned int n,
427 const struct GNUNET_PeerIdentity *needle) 429 const struct GNUNET_PeerIdentity *needle)
428{ 430{
429 unsigned int i; 431 unsigned int i;
432
430 for (i = 0; i < n; i++) 433 for (i = 0; i < n; i++)
431 if (0 == memcmp (&haystack[i], needle, sizeof (struct GNUNET_PeerIdentity))) 434 if (0 == memcmp (&haystack[i],
435 needle,
436 sizeof (struct GNUNET_PeerIdentity)))
432 return i; 437 return i;
433 return -1; 438 return -1;
434} 439}
@@ -468,8 +473,13 @@ normalize_peers (struct GNUNET_PeerIdentity *listed,
468 if (GNUNET_NO == local_peer_in_list) 473 if (GNUNET_NO == local_peer_in_list)
469 normalized[n - 1] = my_peer; 474 normalized[n - 1] = my_peer;
470 475
471 memcpy (normalized, listed, num_listed * sizeof (struct GNUNET_PeerIdentity)); 476 memcpy (normalized,
472 qsort (normalized, n, sizeof (struct GNUNET_PeerIdentity), &peer_id_cmp); 477 listed,
478 num_listed * sizeof (struct GNUNET_PeerIdentity));
479 qsort (normalized,
480 n,
481 sizeof (struct GNUNET_PeerIdentity),
482 &peer_id_cmp);
473 483
474 if (NULL != my_peer_idx) 484 if (NULL != my_peer_idx)
475 *my_peer_idx = peer_find (normalized, n, &my_peer); 485 *my_peer_idx = peer_find (normalized, n, &my_peer);