mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Make the RAII constructor explicit
This commit is contained in:
parent
25ae5a1284
commit
a5de2b33c0
@ -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 *
|
||||||
|
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user