From b249dd9bc94dd6142a167e3fdf340c38b1a45876 Mon Sep 17 00:00:00 2001 From: Sean Hefty Date: Tue, 27 Jul 2010 22:15:04 +0000 Subject: [PATCH] nd2: use private heap Replace the use of the application heap with a private heap. Signed-off-by: Sean Hefty git-svn-id: svn://openib.tc.cornell.edu/gen1@2851 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86 --- trunk/ulp/netdirect2/user/nd_base.h | 9 ++++++--- trunk/ulp/netdirect2/user/nd_main.cpp | 15 +++++++++++++-- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/trunk/ulp/netdirect2/user/nd_base.h b/trunk/ulp/netdirect2/user/nd_base.h index d11b1a0e..855fc673 100644 --- a/trunk/ulp/netdirect2/user/nd_base.h +++ b/trunk/ulp/netdirect2/user/nd_base.h @@ -1,5 +1,6 @@ /* - * Copyright (c) 2009 Intel Corporation. All rights reserved. + * Copyright (c) 2009-2010 Intel Corporation. All rights reserved. + * Copyright (c) 2010 Microsoft Corporation. All rights reserved. * * This software is available to you under the OpenIB.org BSD license * below: @@ -51,14 +52,16 @@ public: protected: }; +extern HANDLE g_hHeap; + __inline void* __cdecl operator new(size_t size) { - return HeapAlloc(GetProcessHeap(), 0, size); + return HeapAlloc(g_hHeap, 0, size); } __inline void __cdecl operator delete(void *pObj) { - HeapFree(GetProcessHeap(), 0, pObj); + HeapFree(g_hHeap, 0, pObj); } HRESULT NDConvertWVStatus(HRESULT hr); diff --git a/trunk/ulp/netdirect2/user/nd_main.cpp b/trunk/ulp/netdirect2/user/nd_main.cpp index a27764de..6fde5de6 100644 --- a/trunk/ulp/netdirect2/user/nd_main.cpp +++ b/trunk/ulp/netdirect2/user/nd_main.cpp @@ -1,5 +1,6 @@ /* - * Copyright (c) 2009 Intel Corporation. All rights reserved. + * Copyright (c) 2009-2010 Intel Corporation. All rights reserved. + * Copyright (c) 2010 Microsoft Corporation. All rights reserved. * * This software is available to you under the OpenIB.org BSD license * below: @@ -32,6 +33,7 @@ #include #include "nd_provider.h" +HANDLE g_hHeap; extern "C" { @@ -44,10 +46,19 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { switch (dwReason) { case DLL_PROCESS_ATTACH: + if (_DllMainCRTStartupForGS(hInstance, dwReason, lpReserved)) { + return FALSE; + } + + g_hHeap = HeapCreate(0, 0, 0); + return (g_hHeap != NULL); case DLL_PROCESS_DETACH: + if (g_hHeap != NULL) { + HeapDestroy(g_hHeap); + } return _DllMainCRTStartupForGS(hInstance, dwReason, lpReserved); default: - return TRUE; + return FALSE; } } -- 2.46.0