fix bad free
[oweals/gnunet.git] / src / core / test_core_api_reliability.c
index 192b5d3d67fc850747d784433078982d5382bd7c..4cc5b4bcda1655f54da3353989be8da501a5ac38 100644 (file)
@@ -2,20 +2,18 @@
      This file is part of GNUnet.
      Copyright (C) 2009, 2010, 2015, 2016 GNUnet e.V.
 
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 3, or (at your
-     option) any later version.
+     GNUnet is free software: you can redistribute it and/or modify it
+     under the terms of the GNU Affero General Public License as published
+     by the Free Software Foundation, either version 3 of the License,
+     or (at your option) any later version.
 
      GNUnet is distributed in the hope that it will be useful, but
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-     Boston, MA 02110-1301, USA.
+     Affero General Public License for more details.
+    
+     You should have received a copy of the GNU Affero General Public License
+     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 /**
  * @file core/test_core_api_reliability.c
  */
 #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 600)
 
-/**
- * What delay do we request from the core service for transmission?
- */
-#define FAST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 5)
-
 #define MTYPE 12345
 
 
@@ -108,7 +101,7 @@ terminate_peer (struct PeerContext *p)
 {
   if (NULL != p->ch)
   {
-    GNUNET_CORE_disconnecT (p->ch);
+    GNUNET_CORE_disconnect (p->ch);
     p->ch = NULL;
   }
   if (NULL != p->ghh)
@@ -164,7 +157,7 @@ do_shutdown (void *cls)
   }
   terminate_peer (&p1);
   terminate_peer (&p2);
-  
+
 }
 
 
@@ -318,7 +311,7 @@ handle_test (void *cls,
     {
       send_message (p1.mq,
                    tr_n);
-    }  
+    }
   }
 }
 
@@ -327,12 +320,12 @@ static void
 init_notify (void *cls,
              const struct GNUNET_PeerIdentity *my_identity)
 {
-  GNUNET_MQ_hd_var_size (test,
-                        MTYPE,
-                        struct TestMessage);
   struct PeerContext *p = cls;
   struct GNUNET_MQ_MessageHandler handlers[] = {
-    make_test_handler (NULL),
+    GNUNET_MQ_hd_var_size (test,
+                           MTYPE,
+                           struct TestMessage,
+                           NULL),
     GNUNET_MQ_handler_end ()
   };
 
@@ -346,7 +339,7 @@ init_notify (void *cls,
     OKPP;
     /* connect p2 */
     GNUNET_assert (NULL !=
-                  (p2.ch = GNUNET_CORE_connecT (p2.cfg,
+                  (p2.ch = GNUNET_CORE_connect (p2.cfg,
                                                 &p2,
                                                 &init_notify,
                                                 &connect_notify,
@@ -386,6 +379,7 @@ process_hello (void *cls,
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Received (my) `%s' from transport service\n", "HELLO");
   GNUNET_assert (message != NULL);
+  GNUNET_free_non_null (p->hello);
   p->hello = GNUNET_copy_message (message);
   if ((p == &p1) && (NULL == p2.oh))
     p2.oh = GNUNET_TRANSPORT_offer_hello (p2.cfg,
@@ -447,11 +441,11 @@ run (void *cls,
      const char *cfgfile,
      const struct GNUNET_CONFIGURATION_Handle *cfg)
 {
-  GNUNET_MQ_hd_fixed_size (test,
-                          MTYPE,
-                          struct TestMessage);
   struct GNUNET_MQ_MessageHandler handlers[] = {
-    make_test_handler (NULL),
+    GNUNET_MQ_hd_fixed_size (test,
+                             MTYPE,
+                             struct TestMessage,
+                             NULL),
     GNUNET_MQ_handler_end ()
   };
 
@@ -469,7 +463,7 @@ run (void *cls,
                                 NULL);
 
   GNUNET_assert (NULL !=
-                (p1.ch = GNUNET_CORE_connecT (p1.cfg,
+                (p1.ch = GNUNET_CORE_connect (p1.cfg,
                                               &p1,
                                               &init_notify,
                                               &connect_notify,
@@ -523,6 +517,8 @@ main (int argc,
                       &ok);
   stop_arm (&p1);
   stop_arm (&p2);
+  GNUNET_free_non_null (p1.hello);
+  GNUNET_free_non_null (p2.hello);
   GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-1");
   GNUNET_DISK_directory_remove ("/tmp/test-gnunet-core-peer-2");