Make the RAII constructor explicit

This commit is contained in:
Kovid Goyal 2021-04-21 08:28:07 +05:30
parent 25ae5a1284
commit a5de2b33c0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 3 additions and 4 deletions

View File

@ -18,7 +18,7 @@ CComPtr<IPortableDeviceManager> wpd::portable_device_manager = NULL;
// Flag indicating if COM has been initialized // Flag indicating if COM has been initialized
static int _com_initialized = 0; static int _com_initialized = 0;
// Application Info // Application Info
wpd::ClientInfo wpd::client_info = {0}; wpd::ClientInfo wpd::client_info;
// Module startup/shutdown {{{ // Module startup/shutdown {{{
static PyObject * static PyObject *

View File

@ -34,11 +34,11 @@ class generic_raii {
generic_raii & operator=( const generic_raii & ) ; generic_raii & operator=( const generic_raii & ) ;
public: public:
generic_raii(T h = null) : handle(h) {} explicit generic_raii(T h = null) : handle(h) {}
~generic_raii() { release(); } ~generic_raii() { release(); }
void release() { void release() {
if (handle) { if (handle != null) {
free_T(handle); free_T(handle);
handle = null; handle = null;
} }
@ -49,7 +49,6 @@ class generic_raii {
void set_ptr(T val) { handle = val; } void set_ptr(T val) { handle = val; }
T* address() { return &handle; } T* address() { return &handle; }
explicit operator bool() const { return handle != null; } explicit operator bool() const { return handle != null; }
T operator->() { return handle; }
}; };
typedef generic_raii<wchar_t*, PyMem_Free, NULL> wchar_raii; typedef generic_raii<wchar_t*, PyMem_Free, NULL> wchar_raii;