Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 25692 invoked from network); 13 Jan 2010 15:48:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 13 Jan 2010 15:48:43 -0000 Received: (qmail 52288 invoked by uid 500); 13 Jan 2010 15:48:43 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 52188 invoked by uid 500); 13 Jan 2010 15:48:42 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 52179 invoked by uid 99); 13 Jan 2010 15:48:42 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2010 15:48:42 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 13 Jan 2010 15:48:40 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 512BC238897D; Wed, 13 Jan 2010 15:48:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r898807 - in /commons/sandbox/runtime/trunk/src/main/native: include/arch/windows/acr_arch_private.h os/win32/main.c os/win32/wusec.c Date: Wed, 13 Jan 2010 15:48:19 -0000 To: commits@commons.apache.org From: mturk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100113154819.512BC238897D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mturk Date: Wed Jan 13 15:48:18 2010 New Revision: 898807 URL: http://svn.apache.org/viewvc?rev=898807&view=rev Log: Add Heap and Local alloc macros 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/wusec.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=898807&r1=898806&r2=898807&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 Wed Jan 13 15:48:18 2010 @@ -270,9 +270,12 @@ */ 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)) +#define ACR_HMALLOC(T, S) (T *)(HeapAlloc(dll_heap_handle, 0, (S))) +#define ACR_HCALLOC(T, S) (T *)(HeapAlloc(dll_heap_handle, HEAP_ZERO_MEMORY, (S))) +#define ACR_HFREE(M) HeapFree(dll_heap_handle, 0, (M)) + +#define ACR_LALLOC(T, S) (T *)(LocalAlloc(LPTR, (S))) +#define ACR_LFREE(M) if ((M)) LocalFree((M)) /** * Utility functions from wutil.c 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=898807&r1=898806&r2=898807&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 Wed Jan 13 15:48:18 2010 @@ -73,9 +73,9 @@ ACR_RING_REMOVE(c, link); if (c->size) x_free(c->data); - ACR_HeapFree(c); + ACR_HFREE(c); } - ACR_HeapFree(t);; + ACR_HFREE(t); } static void acr_dll_exit() @@ -442,7 +442,7 @@ if (tlsd == NULL) { if (GetLastError() != ERROR_SUCCESS) return &_null_tlsd; - tlsd = ACR_HeapCalloc(sizeof(acr_thread_local_t)); + tlsd = ACR_HCALLOC(acr_thread_local_t, sizeof(acr_thread_local_t)); if (tlsd == NULL) { memset(&_null_tlsd, 0, sizeof(acr_thread_local_t)); return &_null_tlsd; @@ -479,7 +479,7 @@ return ACR_EEXIST; } } - node = ACR_HeapCalloc(sizeof(acr_tlsd_data_t)); + node = ACR_HCALLOC(acr_tlsd_data_t, sizeof(acr_tlsd_data_t)); if (!node) { return ACR_ENOMEM; } Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c?rev=898807&r1=898806&r2=898807&view=diff ============================================================================== --- commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c (original) +++ commons/sandbox/runtime/trunk/src/main/native/os/win32/wusec.c Wed Jan 13 15:48:18 2010 @@ -33,7 +33,7 @@ #define SECURITY_UNL() \ if (security_table) \ LeaveCriticalSection(&security_lock) - + PSID ACR_GetSidFromAccountName(LPCWSTR name, PSID_NAME_USE sidtype) { WCHAR domain[MAX_PATH]; @@ -106,7 +106,7 @@ GetTokenInformation(h, ic, NULL, sz, &sz); if ((rc = GetLastError()) != ERROR_INSUFFICIENT_BUFFER) { - if(_E) { + if(IS_VALID_HANDLE(_E)) { rc = ACR_FROM_OS_ERROR(rc); if (ACR_STATUS_IS_EACCES(rc)) ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); @@ -183,7 +183,7 @@ rc = 0; } if (rc != ERROR_SUCCESS) { - if (_E) { + if (IS_VALID_HANDLE(_E)) { if (ACR_STATUS_IS_EACCES(ACR_FROM_OS_ERROR(rc))) ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); else @@ -199,15 +199,15 @@ PSID ACR_AllocateWellKnownSid(JNIEnv *_E, WELL_KNOWN_SID_TYPE type) { DWORD ss = SECURITY_MAX_SID_SIZE; - PSID sid = ACR_HeapMalloc(ss); + PSID sid = ACR_HMALLOC(SID, ss); if (sid) { if (!CreateWellKnownSid(type, NULL, sid, &ss)) { int ec = ACR_GET_OS_ERROR(); - ACR_HeapFree(sid); + ACR_HFREE(sid); sid = NULL; - if (_E) { - if (ACR_STATUS_IS_EACCES(ec)) + if (IS_VALID_HANDLE(_E)) { + if (ACR_STATUS_IS_EACCES(ec)) ACR_ThrowException(_E, THROW_NMARK, ACR_EX_ESECURITY, 0); else ACR_ThrowException(_E, THROW_NMARK, ACR_EX_OSERR, ec); @@ -597,10 +597,10 @@ SECURITY_UNL(); return _null_sa; } - _null_sa = (PSECURITY_ATTRIBUTES)LocalAlloc(LPTR, sizeof(SECURITY_ATTRIBUTES)); + _null_sa = ACR_LALLOC(SECURITY_ATTRIBUTES, sizeof(SECURITY_ATTRIBUTES)); _null_sa->nLength = sizeof(SECURITY_ATTRIBUTES); - pSD = (PSECURITY_DESCRIPTOR)LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); + pSD = ACR_LALLOC(SECURITY_DESCRIPTOR, SECURITY_DESCRIPTOR_MIN_LENGTH); _null_sa->lpSecurityDescriptor = pSD; if (pSD == NULL || _null_sa == NULL) { rc = ACR_ENOMEM; @@ -622,12 +622,9 @@ return _null_sa; cleanup: - if (pSD) - LocalFree(pSD); - if (_null_sa) { - LocalFree(_null_sa); - _null_sa = NULL; - } + ACR_LFREE(pSD); + ACR_LFREE(_null_sa); + _null_sa = &_empty_sa; _null_sa->nLength = sizeof(SECURITY_ATTRIBUTES); _null_sa->lpSecurityDescriptor = NULL;