fix leaks, code cleanup
authorChristian Grothoff <christian@grothoff.org>
Mon, 22 Feb 2010 10:56:16 +0000 (10:56 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 22 Feb 2010 10:56:16 +0000 (10:56 +0000)
src/testing/testing.c
src/testing/testing_group.c

index 3dd4af367e037cbd7901fe3d9ab27f5c2b18f28c..be3e96509e625a69b82589418eaae2666efddec1 100644 (file)
@@ -549,6 +549,7 @@ GNUNET_TESTING_daemon_stop (struct GNUNET_TESTING_Daemon *d,
   GNUNET_free (d->cfgfile);
   GNUNET_free_non_null (d->hostname);
   GNUNET_free_non_null (d->username);
+  GNUNET_free_non_null (d->shortname);
   GNUNET_free (d);
   if (NULL != cb)
     cb (cb_cls, NULL);
@@ -779,7 +780,7 @@ notify_connect_result (void *cls,
   ctx->d2th = NULL;
   GNUNET_CORE_disconnect (ctx->d1core);
   ctx->d1core = NULL;
-
+  GNUNET_free_non_null (ctx->hello);
   GNUNET_free (ctx);
 }
 
index 744e505ce6d4d79fb02012e8174e444e6b435e9a..d019bfd706d2031ea294255af323fa9d426f579d 100644 (file)
@@ -982,7 +982,6 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
   unsigned int off;
   unsigned int hostcnt;
   uint16_t minport;
-  int tempsize;
 
   if (0 == total)
     {
@@ -1073,18 +1072,18 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched,
           GNUNET_CONFIGURATION_get_value_string (pcfg, "PATHS", "SERVICEHOME",
                                                  &baseservicehome))
         {
-          tempsize = snprintf (NULL, 0, "%s/%d/", baseservicehome, off) + 1;
-          newservicehome = GNUNET_malloc (tempsize);
-          snprintf (newservicehome, tempsize, "%s/%d/", baseservicehome, off);
+         GNUNET_asprintf (&newservicehome,
+                          "%s/%d/", baseservicehome, off);
+         GNUNET_free (baseservicehome);
         }
       else
         {
           tmpdir = getenv ("TMPDIR");
           tmpdir = tmpdir ? tmpdir : "/tmp";
-          tempsize = snprintf (NULL, 0, "%s/%s/%d/", tmpdir, "gnunet-testing-test-test", off) + 1;
-          newservicehome = GNUNET_malloc (tempsize);
-          snprintf (newservicehome, tempsize, "%s/%d/",
-                    "/tmp/gnunet-testing-test-test", off);
+         GNUNET_asprintf (&newservicehome,
+                          "%s/%s/%d/",
+                          tmpdir,
+                          "gnunet-testing-test-test", off);
         }
       GNUNET_CONFIGURATION_set_value_string (pcfg,
                                              "PATHS",