gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r34886 - gnunet/src/cadet


From: gnunet
Subject: [GNUnet-SVN] r34886 - gnunet/src/cadet
Date: Thu, 15 Jan 2015 15:19:55 +0100

Author: bartpolot
Date: 2015-01-15 15:19:55 +0100 (Thu, 15 Jan 2015)
New Revision: 34886

Modified:
   gnunet/src/cadet/cadet_path.c
   gnunet/src/cadet/cadet_path.h
Log:
- added path_cmp

Modified: gnunet/src/cadet/cadet_path.c
===================================================================
--- gnunet/src/cadet/cadet_path.c       2015-01-15 13:58:12 UTC (rev 34885)
+++ gnunet/src/cadet/cadet_path.c       2015-01-15 14:19:55 UTC (rev 34886)
@@ -294,6 +294,29 @@
 }
 
 
+/**
+ * Compare two paths.
+ *
+ * @param p1 First path.
+ * @param p2 Second path.
+ *
+ * @return > 0 if p1 is longer, or the first differing PEER_Id is higher on p1.
+ *         < 0 if p2 is longer, or the first differing PEER_Id is higher on p2.
+ *         0 if they are identical.
+ */
+int
+path_cmp (const struct CadetPeerPath *p1, const struct CadetPeerPath *p2)
+{
+  if (p1->length > p2->length)
+    return 1;
+
+  if (p1->length < p2->length)
+    return -1;
+
+  return memcmp (p1->peers, p2->peers, sizeof (GNUNET_PEER_Id) * p1->length);
+}
+
+
 char *
 path_2s (struct CadetPeerPath *p)
 {

Modified: gnunet/src/cadet/cadet_path.h
===================================================================
--- gnunet/src/cadet/cadet_path.h       2015-01-15 13:58:12 UTC (rev 34885)
+++ gnunet/src/cadet/cadet_path.h       2015-01-15 14:19:55 UTC (rev 34886)
@@ -172,6 +172,19 @@
 path_destroy (struct CadetPeerPath *p);
 
 /**
+ * Compare two paths.
+ *
+ * @param p1 First path.
+ * @param p2 Second path.
+ *
+ * @return > 0 if p1 is longer, or the first differing PEER_Id is higher on p1.
+ *         < 0 if p2 is longer, or the first differing PEER_Id is higher on p2.
+ *         0 if they are identical.
+ */
+int
+path_cmp (const struct CadetPeerPath *p1, const struct CadetPeerPath *p2);
+
+/**
  * Builds a path from a PeerIdentity array.
  *
  * @param peers PeerIdentity array.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]