-use loop when looking up session...
authorChristian Grothoff <christian@grothoff.org>
Mon, 13 Feb 2012 15:14:10 +0000 (15:14 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 13 Feb 2012 15:14:10 +0000 (15:14 +0000)
src/transport/plugin_transport_http.c

index 820d51ffc6bfa255c52590907d6f6d541ddec313..e40d2c8f86645762a86b65d09fbb9cb85bcffa5a 100644 (file)
@@ -434,21 +434,13 @@ struct Session *
 lookup_session (struct Plugin *plugin,
                 const struct GNUNET_HELLO_Address *address)
 {
-  struct Session *tmp = NULL;
+  struct Session *pos;
 
-  tmp = plugin->head;
-  if (tmp == NULL)
-    return NULL;
-  while (tmp != NULL)
-  {
-    if (0 != memcmp (&address->peer, &tmp->target, sizeof (struct GNUNET_PeerIdentity)))
-      continue;
-    if ((address->address_length != tmp->addrlen) &&
-        (0 != memcmp (address->address, tmp->addr, tmp->addrlen)))
-      continue;
-
-    return tmp;
-  }
+  for (pos = plugin->head; NULL != pos; pos = pos->next)
+    if ( (0 == memcmp (&address->peer, &pos->target, sizeof (struct GNUNET_PeerIdentity))) &&
+        (address->address_length == pos->addrlen) &&
+        (0 == memcmp (address->address, pos->addr, pos->addrlen)) )
+      return pos;
   return NULL;
 }