Fix memory leak with a proper shutdown of Openssl, thanks to Massimiliano Calamelli...
authorcedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 19 Sep 2008 11:30:42 +0000 (11:30 +0000)
committercedric <cedric@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Fri, 19 Sep 2008 11:30:42 +0000 (11:30 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/eet@36095 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/eet_lib.c

index 1b11655..a3cfb19 100644 (file)
@@ -684,29 +684,28 @@ eet_flush(Eet_File *ef)
 EAPI int
 eet_init(void)
 {
-#ifdef HAVE_OPENSSL
-   /* Just load the crypto library error strings,
-    * SSL_load_error_strings() loads the crypto AND the SSL ones */
-   /* SSL_load_error_strings();*/
-   static int call_once = 0;
+   eet_initcount++;
 
-   if (call_once == 0)
-     {
-       call_once = 1;
-       ERR_load_crypto_strings();
-     }
+   if (eet_initcount > 1) return eet_initcount;
 
+#ifdef HAVE_OPENSSL
+   ERR_load_crypto_strings();
 #endif
-   return ++eet_initcount;
+
+   return eet_initcount;
 }
 
 EAPI int
 eet_shutdown(void)
 {
-   if (--eet_initcount == 0)
-     {
-       eet_clearcache();
-     }
+   eet_initcount--;
+
+   if (eet_initcount > 0) return eet_initcount;
+
+   eet_clearcache();
+#ifdef HAVE_OPENSSL
+   ERR_free_strings();
+#endif
 
    return eet_initcount;
 }