so the next person doesn't waste any time wondering why
authorLee <ler762@users.sourceforge.net>
Sat, 23 Jul 2016 23:05:15 +0000 (23:05 +0000)
committerLee <ler762@users.sourceforge.net>
Sat, 23 Jul 2016 23:05:15 +0000 (23:05 +0000)
it's only on Windows that the memory gets freed

miscutil.c

index f5e647c..10ff9ea 100644 (file)
@@ -1,4 +1,4 @@
-const char miscutil_rcs[] = "$Id: miscutil.c,v 1.80 2016/01/16 12:33:36 fabiankeil Exp $";
+const char miscutil_rcs[] = "$Id: miscutil.c,v 1.81 2016/02/26 12:29:17 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/miscutil.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/miscutil.c,v $
@@ -893,6 +893,16 @@ time_t timegm(struct tm *tm)
          strcat(old_zone, zone);
          putenv(old_zone);
 #ifdef _WIN32
          strcat(old_zone, zone);
          putenv(old_zone);
 #ifdef _WIN32
+         /* http://man7.org/linux/man-pages/man3/putenv.3.html
+          *   int putenv(char *string);
+          *     The string pointed to by string becomes part of the environment, so altering the
+          *     string changes the environment.
+          * In other words, the memory pointed to by *string is used until
+          *   a) another call to putenv() with the same e-var name
+          *   b) the program exits
+          *
+          * Windows e-vars don't work that way, so let's not leak memory.
+          */
          free(old_zone);
 #endif /* def _WIN32 */
       }
          free(old_zone);
 #endif /* def _WIN32 */
       }