[LIBUSB] Add additional operator new/delete

This is required, since newer versions of MSVC demand that non-member operator new/delete are in the global namespace and neither static nor inline. See https://msdn.microsoft.com/en-us/library/mt723604.aspx ("Overloaded operator new and operator delete")
This commit is contained in:
Timo Kreuzer 2018-02-24 11:20:27 +01:00
parent 03830f67a7
commit a262e8da2d
2 changed files with 39 additions and 0 deletions

View file

@ -18,6 +18,36 @@
//
DRIVER_ADD_DEVICE USBLIB_AddDevice;
PVOID
__cdecl
operator new(
size_t iSize,
POOL_TYPE poolType,
ULONG tag)
{
PVOID result = ExAllocatePoolWithTag(poolType, iSize, tag);
if (result) {
RtlZeroMemory(result, iSize);
}
return result;
}
void
__cdecl
operator delete(
PVOID pVoid)
{
if (pVoid) ExFreePool(pVoid);
}
void
__cdecl
operator delete(
PVOID pVoid, UINT_PTR)
{
if (pVoid) ExFreePool(pVoid);
}
extern
"C"
{

View file

@ -22,8 +22,17 @@ extern "C"
// the following includes are required to get kcom to compile
//
#include <portcls.h>
#define _NEW_DELETE_OPERATORS_
#include <kcom.h>
PVOID
__cdecl
operator new(
size_t iSize,
POOL_TYPE poolType,
ULONG tag);
#include "common_interfaces.h"
//