possibly fixing 1840 and/or related issues
authorChristian Grothoff <christian@grothoff.org>
Sun, 23 Oct 2011 13:51:43 +0000 (13:51 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 23 Oct 2011 13:51:43 +0000 (13:51 +0000)
src/core/gnunet-service-core_sessions.c
src/core/gnunet-service-core_typemap.c
src/core/gnunet-service-core_typemap.h

index 61532ac9cf31c0e48256a5468ba9f2ab0ca78a4d..f159da2056cd1dae834009de2505a68eba69d770 100644 (file)
@@ -200,11 +200,8 @@ GSC_SESSIONS_end (const struct GNUNET_PeerIdentity *pid)
                         gettext_noop ("# entries in session map"),
                         GNUNET_CONTAINER_multihashmap_size (sessions), 
                         GNUNET_NO);
-  if (NULL != session->tmap)
-  {
-    GSC_TYPEMAP_destroy (session->tmap);
-    session->tmap = NULL;
-  }
+  GSC_TYPEMAP_destroy (session->tmap);
+  session->tmap = NULL;
   GNUNET_free (session);
 }
 
@@ -260,6 +257,7 @@ GSC_SESSIONS_create (const struct GNUNET_PeerIdentity *peer,
               "Creating session for peer `%4s'\n", GNUNET_i2s (peer));
 #endif
   session = GNUNET_malloc (sizeof (struct Session));
+  session->tmap = GSC_TYPEMAP_create ();
   session->peer = *peer;
   session->kxinfo = kx;
   session->time_established = GNUNET_TIME_absolute_get ();
@@ -767,8 +765,7 @@ GSC_SESSIONS_set_typemap (const struct GNUNET_PeerIdentity *peer,
                                              NULL, 0, /* FIXME: ATS */
                                              session->tmap,
                                              nmap);
-  if (NULL != session->tmap)
-    GSC_TYPEMAP_destroy (session->tmap);
+  GSC_TYPEMAP_destroy (session->tmap);
   session->tmap = nmap;
 }
 
@@ -802,8 +799,7 @@ GSC_SESSIONS_add_to_typemap (const struct GNUNET_PeerIdentity *peer,
                                              NULL, 0, /* FIXME: ATS */
                                              session->tmap,
                                              nmap);
-  if (NULL != session->tmap)
-    GSC_TYPEMAP_destroy (session->tmap);
+  GSC_TYPEMAP_destroy (session->tmap);
   session->tmap = nmap;
 }
 
index e4f75bd0034b09ffcefd6e66a9aa461fd29c362f..5d40820dfd731abf11c942d92800dfb39fad23b0 100644 (file)
@@ -259,6 +259,18 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
 }
 
 
+/**
+ * Create an empty type map.
+ *
+ * @param map a type map
+ */
+struct GSC_TypeMap *
+GSC_TYPEMAP_create ()
+{
+  return GNUNET_malloc (sizeof (struct GSC_TypeMap));
+}
+
+
 /**
  * Free the given type map.
  *
index 72eb5b566713e2dd394a7b3e5e775e55099400e2..d589c0b1c9dde92ea399ecffb144f274c7dc4b73 100644 (file)
@@ -98,6 +98,14 @@ GSC_TYPEMAP_extend (const struct GSC_TypeMap *tmap,
                    const uint16_t *types,
                    unsigned int tcnt);
 
+/**
+ * Create an empty type map.
+ *
+ * @param map a type map
+ */
+struct GSC_TypeMap *
+GSC_TYPEMAP_create (void);
+
 
 /**
  * Free the given type map.