Put all "common" initialisation in the apps_startup() and apps_shutdown()
[openssl.git] / apps / openssl.c
index f8d4ac69d6d596e0789cc1f9932e69ea79e16cdc..0e179d9c339152a6eb669e9ce454360fe71d1c8a 100644 (file)
@@ -227,12 +227,17 @@ int main(int Argc, char *Argv[])
        arg.data=NULL;
        arg.count=0;
 
-       if (getenv("OPENSSL_DEBUG_MEMORY") != NULL)
+       if (getenv("OPENSSL_DEBUG_MEMORY") != NULL) /* if not defined, use compiled-in library defaults */
                {
                if (!(0 == strcmp(getenv("OPENSSL_DEBUG_MEMORY"), "off")))
                        {
                        CRYPTO_malloc_debug_init();
-                       CRYPTO_dbg_set_options(V_CRYPTO_MDEBUG_ALL);
+                       CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
+                       }
+               else
+                       {
+                       /* OPENSSL_DEBUG_MEMORY=off */
+                       CRYPTO_set_mem_debug_functions(0, 0, 0, 0, 0);
                        }
                }
        CRYPTO_mem_ctrl(CRYPTO_MEM_CHECK_ON);
@@ -250,9 +255,6 @@ int main(int Argc, char *Argv[])
                if ((bio_err=BIO_new(BIO_s_file())) != NULL)
                        BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 
-       ERR_load_crypto_strings();
-       ENGINE_load_builtin_engines();
-
        /* Lets load up our environment a little */
        p=getenv("OPENSSL_CONF");
        if (p == NULL)
@@ -345,12 +347,6 @@ end:
                }
        if (prog != NULL) lh_free(prog);
        if (arg.data != NULL) OPENSSL_free(arg.data);
-       ERR_remove_state(0);
-
-       EVP_cleanup();
-       ERR_free_strings();
-       
-        ENGINE_cleanup();
 
        apps_shutdown();