winverbs/libibverbs: use private heap space
authorshefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 23 Sep 2009 21:45:42 +0000 (21:45 +0000)
committershefty <shefty@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Wed, 23 Sep 2009 21:45:42 +0000 (21:45 +0000)
Signed-off-by: Sean Hefty <sean.hefty@intel.com>
git-svn-id: svn://openib.tc.cornell.edu/gen1/trunk@2461 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

core/winverbs/user/wv_main.cpp
core/winverbs/user/wv_memory.h
ulp/libibverbs/src/ibv_main.cpp
ulp/libibverbs/src/ibverbs.h

index d1b5d02..361d04b 100644 (file)
 #include "wv_base.h"\r
 \r
 volatile LONG WvRef;\r
+HANDLE heap;\r
 \r
 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)\r
 {\r
        UNREFERENCED_PARAMETER(hInstance);\r
-       UNREFERENCED_PARAMETER(dwReason);\r
        UNREFERENCED_PARAMETER(lpReserved);\r
 \r
+       switch (dwReason) {\r
+       case DLL_PROCESS_ATTACH:\r
+               heap = HeapCreate(0, 0, 0);\r
+               if (heap == NULL) {\r
+                       return FALSE;\r
+               }\r
+               break;\r
+       case DLL_PROCESS_DETACH:\r
+               HeapDestroy(heap);\r
+               break;\r
+       default:\r
+               break;\r
+       }\r
+\r
        return TRUE;\r
 }\r
 \r
index 17a5953..292c2e4 100644 (file)
 \r
 #include <windows.h>\r
 \r
+extern HANDLE heap;\r
+\r
 __inline void* __cdecl operator new(size_t size)\r
 {\r
-       return HeapAlloc(GetProcessHeap(), 0, size);\r
+       return HeapAlloc(heap, 0, size);\r
 }\r
 \r
 __inline void __cdecl operator delete(void *pObj)\r
 {\r
-       HeapFree(GetProcessHeap(), 0, pObj);\r
+       HeapFree(heap, 0, pObj);\r
 }\r
 \r
 const int WvDefaultBufferSize = 128;\r
@@ -70,4 +72,4 @@ protected:
        void *m_pBuf;\r
 };\r
 \r
-#endif // _WV_MEMORY_H_
\ No newline at end of file
+#endif // _WV_MEMORY_H_\r
index 4b01115..76216e0 100644 (file)
@@ -30,6 +30,7 @@
 #include <windows.h>\r
 \r
 extern CRITICAL_SECTION lock;\r
+HANDLE heap;\r
 \r
 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)\r
 {\r
@@ -38,10 +39,15 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
 \r
        switch (dwReason) {\r
        case DLL_PROCESS_ATTACH:\r
+               heap = HeapCreate(0, 0, 0);\r
+               if (heap == NULL) {\r
+                       return FALSE;\r
+               }\r
                InitializeCriticalSection(&lock);\r
                break;\r
        case DLL_PROCESS_DETACH:\r
                DeleteCriticalSection(&lock);\r
+               HeapDestroy(heap);\r
                break;\r
        default:\r
                break;\r
index baf012c..11458ef 100644 (file)
 #define IB_VERBS_H\r
 \r
 extern COMP_MANAGER comp_mgr;\r
+extern HANDLE heap;\r
 \r
 __inline void* __cdecl operator new(size_t size)\r
 {\r
-       return HeapAlloc(GetProcessHeap(), 0, size);\r
+       return HeapAlloc(heap, 0, size);\r
 }\r
 \r
 __inline void __cdecl operator delete(void *pObj)\r
 {\r
-       HeapFree(GetProcessHeap(), 0, pObj);\r
+       HeapFree(heap, 0, pObj);\r
 }\r
 \r
 #endif /* IB_VERBS_H */\r