Make MSVC happy

This commit is contained in:
Kovid Goyal 2023-01-27 17:44:58 +05:30
parent 31fe61569f
commit fb95b532bd
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 8 additions and 6 deletions

View File

@ -555,7 +555,7 @@ wpd::get_file(IPortableDevice *device, const wchar_t *object_id, PyObject *dest,
return NULL;
}
generic_raii<char*, PyMem_Free> buf(reinterpret_cast<char*>(PyMem_Malloc(bufsize)));
generic_raii<char*, pymem_free> buf(reinterpret_cast<char*>(PyMem_Malloc(bufsize)));
if (!buf) return PyErr_NoMemory();
while (total_read < filesize) {

View File

@ -8,11 +8,11 @@
#pragma once
#define UNICODE
#define PY_SSIZE_T_CLEAN
#include <Windows.h>
#include <windows.h>
#include <atlbase.h>
#include <Python.h>
#include <Objbase.h>
#include <objbase.h>
#include <PortableDeviceApi.h>
#include <PortableDevice.h>
#include "../../../utils/windows/common.h"

View File

@ -47,13 +47,14 @@ class generic_raii {
};
static inline void wchar_raii_free(wchar_t *x) { PyMem_Free(x); }
template<typename T>
static inline void pymem_free(T *x) { PyMem_Free(x); }
#if (defined(__GNUC__) && !defined(__clang__))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wsubobject-linkage"
#endif
class wchar_raii : public generic_raii<wchar_t*, wchar_raii_free, static_cast<wchar_t*>(NULL)> {
class wchar_raii : public generic_raii<wchar_t*, pymem_free> {
#if (defined(__GNUC__) && !defined(__clang__))
#pragma GCC diagnostic pop
#endif

View File

@ -58,7 +58,8 @@ class scoped_com_initializer { // {{{
#define INITIALIZE_COM_IN_FUNCTION scoped_com_initializer com; if (!com) return com.set_python_error();
static inline void co_task_mem_free(wchar_t *x) { CoTaskMemFree(x); }
template<typename T>
static inline void co_task_mem_free(T *x) { CoTaskMemFree(x); }
typedef generic_raii<wchar_t*, co_task_mem_free> com_wchar_raii;
static inline void mapping_raii_free(void *x) { UnmapViewOfFile(x); }