<commit_before>/*
 * $Id$
 *
 * Copyright(C) 1998-2005 <NAME>
 * All rights reserved.
 *
 */

#include <qs.h>

#include <openssl/evp.h>
#include <openssl/ssl.h>
#ifdef _WIN32_WCE
#	include <openssl/rand.h>
#endif

#include "lock.h"
#include "main.h"
#include "smime.h"


/****************************************************************************
 *
 * Global Variables
 *
 */

HINSTANCE g_hInst = 0;
HINSTANCE g_hInstResource = 0;


/****************************************************************************
 *
 * Global Functions
 *
 */

HINSTANCE qscrypto::getInstanceHandle()
{
	return g_hInst;
}

HINSTANCE qscrypto::getResourceHandle()
{
	return g_hInstResource;
}


/****************************************************************************
 *
 * DllMain
 *
 */

BOOL WINAPI DllMain(HANDLE hInst,
					DWORD dwReason,
					LPVOID lpReserved)
{
	switch (dwReason) {
	case DLL_PROCESS_ATTACH:
#ifndef NDEBUG
		{
			TCHAR tsz[32];
			wsprintf(tsz, TEXT("qscrypto: %p\n"), hInst);
			::OutputDebugString(tsz);
		}
#endif
		g_hInst = static_cast<HINSTANCE>(hInst);
		g_hInstResource = g_hInst;
		OpenSSL_add_all_algorithms();
		SSL_library_init();
		CRYPTO_set_locking_callback(&qscrypto::lockCallback);
#ifdef _WIN32_WCE
		// TODO
		// Seed correctly.
		{
			for (int n = 0; n < 1000; ++n) {
				RAND_seed("abcdefg", 7);
				RAND_seed(&n, sizeof(n));
			}
		}
#endif
		break;
	case DLL_PROCESS_DETACH:
		CRYPTO_set_locking_callback(0);
		break;
	case DLL_THREAD_ATTACH:
		break;
	case DLL_THREAD_DETACH:
		break;
	}
	return TRUE;
}<commit_msg>Fix memory leaks. <BTS:868><commit_after>/*
 * $Id$
 *
 * Copyright(C) 1998-2005 <NAME>
 * All rights reserved.
 *
 */

#include <qs.h>

#include <openssl/err.h>
#include <openssl/evp.h>
#include <openssl/ssl.h>
#ifdef _WIN32_WCE
#	include <openssl/rand.h>
#endif

#include "lock.h"
#include "main.h"
#include "smime.h"


/****************************************************************************
 *
 * Global Variables
 *
 */

HINSTANCE g_hInst = 0;
HINSTANCE g_hInstResource = 0;


/****************************************************************************
 *
 * Global Functions
 *
 */

HINSTANCE qscrypto::getInstanceHandle()
{
	return g_hInst;
}

HINSTANCE qscrypto::getResourceHandle()
{
	return g_hInstResource;
}


/****************************************************************************
 *
 * DllMain
 *
 */

BOOL WINAPI DllMain(HANDLE hInst,
					DWORD dwReason,
					LPVOID lpReserved)
{
	switch (dwReason) {
	case DLL_PROCESS_ATTACH:
#ifndef NDEBUG
		{
			TCHAR tsz[32];
			wsprintf(tsz, TEXT("qscrypto: %p\n"), hInst);
			::OutputDebugString(tsz);
		}
#endif
		g_hInst = static_cast<HINSTANCE>(hInst);
		g_hInstResource = g_hInst;
		OpenSSL_add_all_algorithms();
		SSL_library_init();
		CRYPTO_set_locking_callback(&qscrypto::lockCallback);
#ifdef _WIN32_WCE
		// TODO
		// Seed correctly.
		{
			for (int n = 0; n < 1000; ++n) {
				RAND_seed("abcdefg", 7);
				RAND_seed(&n, sizeof(n));
			}
		}
#endif
		break;
	case DLL_PROCESS_DETACH:
		CRYPTO_set_locking_callback(0);
		break;
	case DLL_THREAD_ATTACH:
		break;
	case DLL_THREAD_DETACH:
		ERR_remove_state(0);
		break;
	}
	return TRUE;
}
{'fraction_non_alphanumeric': 0.26561514195583596, 'fraction_numerical': 0.015772870662460567, 'mean_word_length': 4.602473498233215, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5596688', 'n_tokens_mistral': 1308, 'n_tokens_neox': 1144, 'n_words': 212}