YR_API int yr_finalize(void) { #if defined HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER < 0x10100000L int i; #endif // yr_finalize shouldn't be called without calling yr_initialize first if (init_count == 0) return ERROR_INTERNAL_FATAL_ERROR; yr_re_finalize_thread(); init_count--; if (init_count > 0) return ERROR_SUCCESS; #if defined HAVE_LIBCRYPTO && OPENSSL_VERSION_NUMBER < 0x10100000L for (i = 0; i < CRYPTO_num_locks(); i ++) yr_mutex_destroy(&openssl_locks[i]); OPENSSL_free(openssl_locks); #endif FAIL_ON_ERROR(yr_thread_storage_destroy(&tidx_key)); FAIL_ON_ERROR(yr_thread_storage_destroy(&recovery_state_key)); FAIL_ON_ERROR(yr_re_finalize()); FAIL_ON_ERROR(yr_modules_finalize()); FAIL_ON_ERROR(yr_heap_free()); return ERROR_SUCCESS; }
int yr_re_finalize(void) { yr_thread_storage_destroy(&thread_storage_key); thread_storage_key = 0; return ERROR_SUCCESS; }