Clean up environment at exit.
[gedcom-parse.git] / gedcom / encoding.c
index 07a95891e6bfa29c9a52c6fbc619479e29975031..b5e2b40b148d99ae0a7e8cfca253bd5f6fb30d15 100644 (file)
@@ -107,9 +107,15 @@ char* get_encoding(const char* gedcom_n, ENCODING enc)
   }
 }
 
+static char *new_gconv_path;
+
 void cleanup_encodings()
 {
   hash_free(encodings);
+  /* Clean up environment */
+  putenv(GCONV_SEARCH_PATH);
+  if (new_gconv_path)
+    free(new_gconv_path);
 }
 
 /* Let function be called before main() */
@@ -140,7 +146,6 @@ void update_gconv_search_path()
   /* Add gedcom data directory to gconv search path */
   gconv_path = getenv(GCONV_SEARCH_PATH);
   if (gconv_path == NULL || strstr(gconv_path, PKGDATADIR) == NULL) {
-    char *new_gconv_path;
     if (gconv_path == NULL) {
       new_gconv_path = (char *)malloc(strlen(GCONV_SEARCH_PATH)
                                      + strlen(PKGDATADIR)