Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#ccccFF
char const *env;
char *copy_of_env;

if ((env = getenv("TEST_ENV"));
if (env != NULL) {
   copy_of_env = (char *)malloc(strlen(env) + 1);

   if (copy_of_env != NULL) {
      strcpy(copy_of_env, env);
   }
   else {
      /* Error handling */
   }

   copy_of_env[0] = 'a';
}

...

Code Block
bgColor#ccccFF
char const *env;
char *copy_of_env;

if ((env = getenv("TEST_ENV"));
if (env != NULL) {
   copy_of_env = (char *)malloc(sizeof("TEST_ENV=") + strlen(env));

   if (copy_of_env != NULL) {
      strcpy(copy_of_env, "TEST_ENV=");
      strcat(copy_of_env, env);
      copy_of_env[sizeof("TEST_ENV=") - 1] = 'a';
      if (putenv(copy_of_env) != 0) {
        /* handle error */
      }
   }
   else {
      /* Error handling */
   }
}

...