Base code merged to SPIN 2.4
[platform/upstream/curl.git] / src / tool_main.c
index ef96dc3..9a5ceba 100644 (file)
 #include <signal.h>
 #endif
 
+#ifdef USE_NSS
+#include <nspr.h>
+#include <plarenas.h>
+#endif
+
 #define ENABLE_CURLX_PRINTF
 /* use our own printf() functions */
 #include "curlx.h"
@@ -205,6 +210,14 @@ static void main_free(struct GlobalConfig *config)
   curl_global_cleanup();
   convert_cleanup();
   metalink_cleanup();
+#ifdef USE_NSS
+  if(PR_Initialized()) {
+    /* prevent valgrind from reporting still reachable mem from NSRP arenas */
+    PL_ArenaFinish();
+    /* prevent valgrind from reporting possibly lost memory (fd cache, ...) */
+    PR_Cleanup();
+  }
+#endif
   free_config_fields(config);
 
   /* Free the config structures */
@@ -253,7 +266,7 @@ int main(int argc, char *argv[])
 #endif
 
 #ifdef __VMS
-  vms_special_exit(res, vms_show);
+  vms_special_exit(result, vms_show);
 #else
   return (int)result;
 #endif