- unique constraint
[oweals/gnunet.git] / src / testbed / gnunet-helper-testbed.c
index 6b080cfa9a132fed356866e7392d14f0aa8c92e7..e8c70a3543fba196814b2b9eeb5453d53c13ee56 100644 (file)
@@ -406,9 +406,10 @@ tokenizer_cb (void *cls, void *client,
   evstr = getenv (GNUNET_TESTING_PREFIX);
   if (NULL != evstr)
   {
-#if WINDOWS
-    static char *evar = GNUNET_TESTING_PREFIX "=";
-    GNUNET_break (0 == putenv (evar));
+    /* unsetting the variable will invalidate the pointer! */
+    evstr = GNUNET_strdup (evstr);
+#ifdef WINDOWS
+    GNUNET_break (0 != SetEnvironmentVariable (GNUNET_TESTING_PREFIX, NULL));
 #else
     GNUNET_break (0 == unsetenv (GNUNET_TESTING_PREFIX));
 #endif
@@ -418,12 +419,16 @@ tokenizer_cb (void *cls, void *client,
                                     NULL);
   if (NULL != evstr)
   {
+#ifdef WINDOWS
+    GNUNET_assert (0 != SetEnvironmentVariable (GNUNET_TESTING_PREFIX, evstr));
+#else
     static char evar[2* PATH_MAX];
 
     GNUNET_assert (0 < GNUNET_snprintf (evar, sizeof (evar),
                                         GNUNET_TESTING_PREFIX "=%s", evstr));
     putenv (evar);
-    /* do not free evstr */
+#endif
+    GNUNET_free (evstr);
     evstr = NULL;
   }
   GNUNET_free_non_null (hostname);
@@ -475,7 +480,7 @@ tokenizer_cb (void *cls, void *client,
   xconfig_size =
       GNUNET_TESTBED_compress_config_ (config, config_size, &xconfig);
   GNUNET_free (config);
-  wc = GNUNET_malloc (sizeof (struct WriteContext));
+  wc = GNUNET_new (struct WriteContext);
   wc->length = xconfig_size + sizeof (struct GNUNET_TESTBED_HelperReply);
   reply = GNUNET_realloc (xconfig, wc->length);
   memmove (&reply[1], reply, xconfig_size);