Reuse free_internal() when destructing the handle<> implementations
Depending on the settings, compiler inlines the free_internal() call inside the destructor. No need to copy&paste code. Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
parent
4520593e49
commit
04c2f9b9c3
@ -143,7 +143,7 @@ namespace winstd
|
||||
virtual ~com_obj()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
m_h->Release();
|
||||
free_internal();
|
||||
}
|
||||
|
||||
|
||||
@ -262,7 +262,7 @@ namespace winstd
|
||||
virtual ~bstr()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
SysFreeString(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -128,7 +128,7 @@ namespace winstd
|
||||
virtual ~cert_context()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CertFreeCertificateContext(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -278,7 +278,7 @@ namespace winstd
|
||||
virtual ~cert_chain_context()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CertFreeCertificateChain(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -343,7 +343,7 @@ namespace winstd
|
||||
virtual ~cert_store()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CertCloseStore(m_h, 0);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -413,7 +413,7 @@ namespace winstd
|
||||
virtual ~crypt_prov()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CryptReleaseContext(m_h, 0);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -464,7 +464,7 @@ namespace winstd
|
||||
virtual ~crypt_hash()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CryptDestroyHash(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -530,7 +530,7 @@ namespace winstd
|
||||
virtual ~crypt_key()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CryptDestroyKey(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -438,7 +438,7 @@ namespace winstd
|
||||
virtual ~eap_packet()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
HeapFree(GetProcessHeap(), 0, m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
|
||||
|
@ -480,7 +480,7 @@ namespace winstd
|
||||
virtual ~event_provider()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
EventUnregister(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
|
||||
@ -753,7 +753,7 @@ namespace winstd
|
||||
virtual ~event_session()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
ControlTrace(m_h, name(), m_prop.get(), EVENT_TRACE_CONTROL_STOP);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
|
||||
@ -913,7 +913,7 @@ namespace winstd
|
||||
virtual ~event_trace()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CloseTrace(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace winstd
|
||||
virtual ~gdi_handle()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
DeleteObject(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -76,7 +76,7 @@ namespace winstd
|
||||
virtual ~dc()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
DeleteDC(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -130,7 +130,7 @@ namespace winstd
|
||||
virtual ~window_dc()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
ReleaseDC(m_hwnd, m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -98,10 +98,8 @@ namespace winstd
|
||||
///
|
||||
virtual ~sec_credentials()
|
||||
{
|
||||
if (m_h != invalid) {
|
||||
FreeCredentialsHandle(m_h);
|
||||
delete m_h;
|
||||
}
|
||||
if (m_h != invalid)
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -199,10 +197,8 @@ namespace winstd
|
||||
///
|
||||
virtual ~sec_context()
|
||||
{
|
||||
if (m_h != invalid) {
|
||||
DeleteSecurityContext(m_h);
|
||||
delete m_h;
|
||||
}
|
||||
if (m_h != invalid)
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -44,7 +44,7 @@ namespace winstd
|
||||
virtual ~setup_device_info_list()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
SetupDiDestroyDeviceInfoList(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -124,7 +124,7 @@ namespace winstd
|
||||
virtual ~wlan_handle()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
WlanCloseHandle(m_h, NULL);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -437,7 +437,7 @@ namespace winstd
|
||||
virtual ~win_handle()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
CloseHandle(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
protected:
|
||||
@ -469,7 +469,7 @@ namespace winstd
|
||||
virtual ~library()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
FreeLibrary(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -667,9 +667,8 @@ namespace winstd
|
||||
///
|
||||
virtual ~find_file()
|
||||
{
|
||||
if (m_h != invalid) {
|
||||
FindClose(m_h);
|
||||
}
|
||||
if (m_h != invalid)
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -719,10 +718,8 @@ namespace winstd
|
||||
///
|
||||
virtual ~heap()
|
||||
{
|
||||
if (m_h != invalid) {
|
||||
enumerate();
|
||||
HeapDestroy(m_h);
|
||||
}
|
||||
if (m_h != invalid)
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -1168,7 +1165,7 @@ namespace winstd
|
||||
virtual ~reg_key()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
RegCloseKey(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
///
|
||||
@ -1300,7 +1297,7 @@ namespace winstd
|
||||
virtual ~security_id()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
FreeSid(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@ -138,7 +138,7 @@ namespace winstd
|
||||
virtual ~addrinfo()
|
||||
{
|
||||
if (m_h != invalid)
|
||||
FreeAddrInfo(m_h);
|
||||
free_internal();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user