You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/14 16:16:14 UTC
svn commit: r1092262 -
/commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
Author: mturk
Date: Thu Apr 14 14:16:14 2011
New Revision: 1092262
URL: http://svn.apache.org/viewvc?rev=1092262&view=rev
Log:
Use CRT instead heap allocation where possible
Modified:
commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c?rev=1092262&r1=1092261&r2=1092262&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/winapi.c Thu Apr 14 14:16:14 2011
@@ -45,16 +45,16 @@ static PSECURITY_ATTRIBUTES GetSaWithNul
_zero_SA[si].lpSecurityDescriptor = 0;
}
- if (!(_null_SA[si] = LocalAlloc(LPTR, sizeof(SECURITY_ATTRIBUTES)))) {
- rc = GetLastError();
+ if (!(_null_SA[si] = malloc(sizeof(SECURITY_ATTRIBUTES)))) {
+ rc = ACR_ENOMEM;
ACR_THROW(ACR_EX_ENOMEM, 0);
goto cleanup;
}
_null_SA[si]->nLength = TSIZEOF(DWORD, SECURITY_ATTRIBUTES);
- pSD = LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH);
+ pSD = malloc(SECURITY_DESCRIPTOR_MIN_LENGTH);
if (pSD == 0) {
- rc = GetLastError();
+ rc = ACR_ENOMEM;
ACR_THROW(ACR_EX_ENOMEM, 0);
goto cleanup;
}
@@ -73,11 +73,8 @@ static PSECURITY_ATTRIBUTES GetSaWithNul
return _null_SA[si];
cleanup:
- if (pSD != 0)
- LocalFree(pSD);
- if (_null_SA[si] != 0)
- LocalFree(_null_SA[si]);
-
+ AcrFree(pSD);
+ AcrFree(_null_SA[si]);
_null_SA[si] = &_zero_SA[si];
_null_SA[si]->bInheritHandle = inherit;
@@ -142,12 +139,12 @@ ACR_WIN_EXPORT(jlong, Api, AllocateWellK
DWORD ss = SECURITY_MAX_SID_SIZE;
PSID sid;
- if (!(sid = (PSID)LocalAlloc(LMEM_FIXED, ss))) {
+ if ((sid = (PSID)malloc(ss)) == 0) {
ACR_THROW(ACR_EX_ENOMEM, 0);
return 0;
}
if (!CreateWellKnownSid(type, 0, sid, &ss)) {
- LocalFree(sid);
+ AcrFree(sid);
sid = 0;
}
return P2J(sid);