commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r770632 - in /commons/sandbox/runtime/trunk/src/main/native: include/arch/windows/acr_arch_private.h os/win32/main.c os/win32/platform.c
Date Fri, 01 May 2009 10:56:05 GMT
Author: mturk
Date: Fri May  1 10:56:04 2009
New Revision: 770632

URL: http://svn.apache.org/viewvc?rev=770632&view=rev
Log:
Use Heap instead Local alloc

Modified:
    commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
    commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c

Modified: commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h?rev=770632&r1=770631&r2=770632&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
(original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/arch/windows/acr_arch_private.h
Fri May  1 10:56:04 2009
@@ -62,9 +62,18 @@
 /**
  * Local functions from user.c
  */
-PSID ACR_GetSidFromAccountName(LPCWSTR name, PSID_NAME_USE sidtype);
+PSID         ACR_GetSidFromAccountName(LPCWSTR name, PSID_NAME_USE sidtype);
 SID_NAME_USE ACR_GetAccountNameFromSid(LPWSTR buf, size_t blen, PSID psid);
+LPVOID       ACR_GetTokenInformation(JNIEnv *_E, HANDLE h, TOKEN_INFORMATION_CLASS ic);
 
+/**
+ * Heap allocation from main.c
+ */
+extern HANDLE dll_heap_handle;
+
+#define ACR_HeapMalloc(S)   HeapAlloc(dll_heap_handle, 0, (S))
+#define ACR_HeapCalloc(S)   HeapAlloc(dll_heap_handle, HEAP_ZERO_MEMORY, (S))
+#define ACR_HeapFree(M)     HeapFree(dll_heap_handle, 0, (M))
 
 #ifdef __cplusplus
 }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c?rev=770632&r1=770631&r2=770632&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/main.c Fri May  1 10:56:04 2009
@@ -31,6 +31,7 @@
 static HINSTANCE        dll_instance = NULL;
 static WCHAR            dll_file_name[ACR_HBUFF_SIZ];
 static DWORD            dll_tls_index = TLS_OUT_OF_INDEXES;
+HANDLE                  dll_heap_handle = NULL;
 
 static SYSTEM_INFO      osinf;
 static OSVERSIONINFOEXA osver;
@@ -62,6 +63,11 @@
         case DLL_PROCESS_ATTACH:
             dll_instance = instance;
             GetModuleFileNameW(instance, dll_file_name, ACR_HBUFF_LEN);
+            dll_heap_handle = GetProcessHeap();
+            if (!dll_heap_handle) {
+                /* No point to continue if we are missing the process heap */
+                return FALSE;
+            }
         break;
         /** The attached process creates a new thread.
          */
@@ -76,7 +82,7 @@
                     if (acr_pvm && tlsd->attached) {
                         (*acr_pvm)->DetachCurrentThread(acr_pvm);
                     }
-                    LocalFree(tlsd);
+                    ACR_HeapFree(tlsd);
                 }
             }
         break;
@@ -85,11 +91,11 @@
          */
         case DLL_PROCESS_DETACH:
             if (acr_everyone_sid) {
-                LocalFree(acr_everyone_sid);
+                ACR_HeapFree(acr_everyone_sid);
                 acr_everyone_sid = NULL;
             }
             if (acr_adminsgr_sid) {
-                LocalFree(acr_adminsgr_sid);
+                ACR_HeapFree(acr_adminsgr_sid);
                 acr_adminsgr_sid = NULL;
             }
             if (dll_tls_index != TLS_OUT_OF_INDEXES) {
@@ -98,7 +104,7 @@
                     if (acr_pvm && tlsd->attached) {
                         (*acr_pvm)->DetachCurrentThread(acr_pvm);
                     }
-                    LocalFree(tlsd);
+                    ACR_HeapFree(tlsd);
                 }
                 TlsFree(dll_tls_index);
             }
@@ -354,8 +360,7 @@
     }
     tlsd = (acr_thread_local_t *)TlsGetValue(dll_tls_index);
     if (tlsd == NULL) {
-        tlsd = (acr_thread_local_t *)LocalAlloc(LPTR,
-                                                sizeof(acr_thread_local_t));
+        tlsd = (acr_thread_local_t *)ACR_HeapCalloc(sizeof(acr_thread_local_t));
         if (tlsd == NULL)
             return NULL;
         if ((*acr_pvm)->GetEnv(acr_pvm, &epp,
@@ -363,8 +368,6 @@
             (*acr_pvm)->AttachCurrentThread(acr_pvm, &epp, NULL);
             tlsd->attached = 1;
         }
-        else
-            tlsd->attached = 0;
         tlsd->env = epp;
         TlsSetValue(dll_tls_index, tlsd);
     }

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c?rev=770632&r1=770631&r2=770632&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/platform.c Fri May  1 10:56:04
2009
@@ -49,11 +49,11 @@
     if (!acr_everyone_sid) {
         /* Create a well known SID for Everyone group. */
         DWORD ss = SECURITY_MAX_SID_SIZE;
-        PSID sid = LocalAlloc(LMEM_FIXED, ss);
+        PSID sid =  ACR_HeapMalloc(ss);
         if (sid) {
             if (!CreateWellKnownSid(WinWorldSid,
                                     NULL, sid, &ss))
-                LocalFree(sid);
+                ACR_HeapFree(sid);
             else
                 acr_everyone_sid = sid;
         }
@@ -61,11 +61,11 @@
     if (!acr_adminsgr_sid) {
         /* Create a well known SID for BUILTIN\Administrators group. */
         DWORD ss = SECURITY_MAX_SID_SIZE;
-        PSID sid = LocalAlloc(LMEM_FIXED, ss);
+        PSID sid = ACR_HeapMalloc(ss);
         if (sid) {
             if (!CreateWellKnownSid(WinBuiltinAdministratorsSid,
                                     NULL, sid, &ss))
-                LocalFree(sid);
+                ACR_HeapFree(sid);
             else
                 acr_adminsgr_sid = sid;
         }



Mime
View raw message