gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r32598 - gnunet/src/mesh


From: gnunet
Subject: [GNUnet-SVN] r32598 - gnunet/src/mesh
Date: Mon, 10 Mar 2014 10:52:43 +0100

Author: bartpolot
Date: 2014-03-10 10:52:43 +0100 (Mon, 10 Mar 2014)
New Revision: 32598

Modified:
   gnunet/src/mesh/gnunet-service-mesh_connection.c
   gnunet/src/mesh/mesh.h
   gnunet/src/mesh/mesh_common.c
Log:
- refactor

Modified: gnunet/src/mesh/gnunet-service-mesh_connection.c
===================================================================
--- gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-03-10 09:52:42 UTC 
(rev 32597)
+++ gnunet/src/mesh/gnunet-service-mesh_connection.c    2014-03-10 09:52:43 UTC 
(rev 32598)
@@ -415,14 +415,7 @@
 static struct MeshConnection *
 connection_get (const struct GNUNET_MeshHash *cid)
 {
-  struct GNUNET_HashCode hash;
-  struct GNUNET_MeshHash *aux;
-
-  memcpy (&hash, cid, sizeof (cid));
-  aux = (struct GNUNET_MeshHash *) &hash;
-  memset (&aux[1], 0, sizeof (hash) - sizeof (*cid));
-
-  return GNUNET_CONTAINER_multihashmap_get (connections, &hash);
+  return GNUNET_CONTAINER_multihashmap_get (connections, GM_h2hc (cid));
 }
 
 

Modified: gnunet/src/mesh/mesh.h
===================================================================
--- gnunet/src/mesh/mesh.h      2014-03-10 09:52:42 UTC (rev 32597)
+++ gnunet/src/mesh/mesh.h      2014-03-10 09:52:43 UTC (rev 32598)
@@ -322,6 +322,17 @@
 
 
 /**
+ * Convert a 256 bit MeshHash into a 512 HashCode to use in GNUNET_h2s,
+ * multihashmap, and other HashCode-based functions.
+ *
+ * @param id A 256 bit hash to expand.
+ *
+ * @return A HashCode containing the original 256 bit hash right-padded with 0.
+ */
+struct GNUNET_HashCode *
+GM_h2hc (const struct GNUNET_MeshHash *id);
+
+/**
  * Convert a message type into a string to help debug
  * Generated with:
  * FIND:        "#define ([^ ]+)[ ]*([0-9]+)"

Modified: gnunet/src/mesh/mesh_common.c
===================================================================
--- gnunet/src/mesh/mesh_common.c       2014-03-10 09:52:42 UTC (rev 32597)
+++ gnunet/src/mesh/mesh_common.c       2014-03-10 09:52:43 UTC (rev 32598)
@@ -77,6 +77,16 @@
 }
 
 
+struct GNUNET_HashCode *
+GM_h2hc (const struct GNUNET_MeshHash *id)
+{
+  static struct GNUNET_HashCode hc;
+  memcpy (&hc, id, sizeof (*id));
+
+  return &hc;
+}
+
+
 #if !defined(GNUNET_CULL_LOGGING)
 const char *
 GM_m2s (uint16_t m)




reply via email to

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