https://git.reactos.org/?p=reactos.git;a=commitdiff;h=a262e8da2d5a4ea474b8a31a649775aea66276d6
commit a262e8da2d5a4ea474b8a31a649775aea66276d6 Author: Timo Kreuzer <timo.kreu...@reactos.org> AuthorDate: Sat Feb 24 11:20:27 2018 +0100 Commit: Timo Kreuzer <timo.kreu...@reactos.org> CommitDate: Sun Jul 1 14:45:21 2018 +0200 [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") --- sdk/lib/drivers/libusb/libusb.cpp | 30 ++++++++++++++++++++++++++++++ sdk/lib/drivers/libusb/libusb.h | 9 +++++++++ 2 files changed, 39 insertions(+) diff --git a/sdk/lib/drivers/libusb/libusb.cpp b/sdk/lib/drivers/libusb/libusb.cpp index f5dc0f17f4..632614803d 100644 --- a/sdk/lib/drivers/libusb/libusb.cpp +++ b/sdk/lib/drivers/libusb/libusb.cpp @@ -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" { diff --git a/sdk/lib/drivers/libusb/libusb.h b/sdk/lib/drivers/libusb/libusb.h index f24190183a..004c2f0a25 100644 --- a/sdk/lib/drivers/libusb/libusb.h +++ b/sdk/lib/drivers/libusb/libusb.h @@ -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" //