Replace the use of the application heap with a private heap.

Signed-off-by: Sean Hefty <[email protected]>
---
 trunk/ulp/netdirect2/user/nd_base.h   |    6 ++++--
 trunk/ulp/netdirect2/user/nd_main.cpp |   12 +++++++++++-
 2 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/trunk/ulp/netdirect2/user/nd_base.h 
b/trunk/ulp/netdirect2/user/nd_base.h
index d11b1a0..23dd59e 100644
--- a/trunk/ulp/netdirect2/user/nd_base.h
+++ b/trunk/ulp/netdirect2/user/nd_base.h
@@ -51,14 +51,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 a27764d..43c2009 100644
--- a/trunk/ulp/netdirect2/user/nd_main.cpp
+++ b/trunk/ulp/netdirect2/user/nd_main.cpp
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include "nd_provider.h"
 
+HANDLE g_hHeap;
 
 extern "C" {
 
@@ -44,10 +45,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;
        }
 }
 

_______________________________________________
ofw mailing list
[email protected]
http://lists.openfabrics.org/cgi-bin/mailman/listinfo/ofw

Reply via email to