Commit 7abcc312 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

advapi32: Use CRT allocation functions.

parent fd67d678
...@@ -252,9 +252,9 @@ BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassw ...@@ -252,9 +252,9 @@ BOOL WINAPI LogonUserA( LPCSTR lpszUsername, LPCSTR lpszDomain, LPCSTR lpszPassw
ret = LogonUserW( usernameW, domainW, passwordW, dwLogonType, dwLogonProvider, phToken ); ret = LogonUserW( usernameW, domainW, passwordW, dwLogonType, dwLogonProvider, phToken );
done: done:
heap_free( usernameW ); free( usernameW );
heap_free( domainW ); free( domainW );
heap_free( passwordW ); free( passwordW );
return ret; return ret;
} }
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "ntsecapi.h" #include "ntsecapi.h"
#include "winsvc.h" #include "winsvc.h"
#include "winnls.h" #include "winnls.h"
#include "wine/heap.h"
const char * debugstr_sid(PSID sid); const char * debugstr_sid(PSID sid);
BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName); BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName);
...@@ -41,7 +40,7 @@ static inline WCHAR *strdupAW( const char *src ) ...@@ -41,7 +40,7 @@ static inline WCHAR *strdupAW( const char *src )
if (src) if (src)
{ {
DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 ); DWORD len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
if ((dst = heap_alloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len ); if ((dst = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
} }
return dst; return dst;
} }
......
...@@ -58,7 +58,7 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) ...@@ -58,7 +58,7 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
backupW = strdupAW(lpBackupFileName); backupW = strdupAW(lpBackupFileName);
ret = BackupEventLogW(hEventLog, backupW); ret = BackupEventLogW(hEventLog, backupW);
heap_free(backupW); free(backupW);
return ret; return ret;
} }
...@@ -115,7 +115,7 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName ) ...@@ -115,7 +115,7 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
backupW = strdupAW(lpBackupFileName); backupW = strdupAW(lpBackupFileName);
ret = ClearEventLogW(hEventLog, backupW); ret = ClearEventLogW(hEventLog, backupW);
heap_free(backupW); free(backupW);
return ret; return ret;
} }
...@@ -394,8 +394,8 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName ) ...@@ -394,8 +394,8 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
uncnameW = strdupAW(lpUNCServerName); uncnameW = strdupAW(lpUNCServerName);
filenameW = strdupAW(lpFileName); filenameW = strdupAW(lpFileName);
handle = OpenBackupEventLogW(uncnameW, filenameW); handle = OpenBackupEventLogW(uncnameW, filenameW);
heap_free(uncnameW); free(uncnameW);
heap_free(filenameW); free(filenameW);
return handle; return handle;
} }
...@@ -453,8 +453,8 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source ) ...@@ -453,8 +453,8 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
uncnameW = strdupAW(uncname); uncnameW = strdupAW(uncname);
sourceW = strdupAW(source); sourceW = strdupAW(source);
handle = OpenEventLogW(uncnameW, sourceW); handle = OpenEventLogW(uncnameW, sourceW);
heap_free(uncnameW); free(uncnameW);
heap_free(sourceW); free(sourceW);
return handle; return handle;
} }
...@@ -608,7 +608,7 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d ...@@ -608,7 +608,7 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d
if (wNumStrings == 0) return TRUE; if (wNumStrings == 0) return TRUE;
if (!lpStrings) return TRUE; if (!lpStrings) return TRUE;
wideStrArray = heap_alloc(sizeof(LPWSTR) * wNumStrings); wideStrArray = malloc(sizeof(WCHAR *) * wNumStrings);
for (i = 0; i < wNumStrings; i++) for (i = 0; i < wNumStrings; i++)
{ {
RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]); RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]);
...@@ -617,8 +617,8 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d ...@@ -617,8 +617,8 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d
ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid, ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid,
wNumStrings, dwDataSize, (LPCWSTR *)wideStrArray, lpRawData); wNumStrings, dwDataSize, (LPCWSTR *)wideStrArray, lpRawData);
for (i = 0; i < wNumStrings; i++) for (i = 0; i < wNumStrings; i++)
heap_free( wideStrArray[i] ); free(wideStrArray[i]);
heap_free(wideStrArray); free(wideStrArray);
return ret; return ret;
} }
......
...@@ -103,7 +103,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs) ...@@ -103,7 +103,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, NULL, &size); ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, NULL, &size);
if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS) if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
{ {
ptr = heap_alloc_zero(sz + size); ptr = calloc(1, sz + size);
if (!ptr) return NULL; if (!ptr) return NULL;
ustr = (UNICODE_STRING*)(ptr + ofs); ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = size; ustr->MaximumLength = size;
...@@ -111,16 +111,16 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs) ...@@ -111,16 +111,16 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, (LPBYTE)ustr->Buffer, &size); ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, (LPBYTE)ustr->Buffer, &size);
if (ret != ERROR_SUCCESS) if (ret != ERROR_SUCCESS)
{ {
heap_free(ptr); free(ptr);
ptr = NULL; ptr = NULL;
} }
else ustr->Length = size - sizeof(WCHAR); else ustr->Length = size - sizeof(WCHAR);
} }
RegCloseKey(key); RegCloseKey(key);
} }
if (!ptr) if (!ptr)
{ {
ptr = heap_alloc_zero(sz + sizeof(L"DOMAIN")); ptr = calloc(1, sz + sizeof(L"DOMAIN"));
if (!ptr) return NULL; if (!ptr) return NULL;
ustr = (UNICODE_STRING*)(ptr + ofs); ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = sizeof(L"DOMAIN"); ustr->MaximumLength = sizeof(L"DOMAIN");
...@@ -144,7 +144,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma ...@@ -144,7 +144,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
if (GetUserNameW(NULL, &user_size) || GetLastError() != ERROR_INSUFFICIENT_BUFFER) if (GetUserNameW(NULL, &user_size) || GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
user = heap_alloc(sizeof(*user) + user_size * sizeof(WCHAR)); user = malloc(sizeof(*user) + user_size * sizeof(WCHAR));
if (!user) return STATUS_NO_MEMORY; if (!user) return STATUS_NO_MEMORY;
user->Buffer = (WCHAR *)(user + 1); user->Buffer = (WCHAR *)(user + 1);
...@@ -152,7 +152,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma ...@@ -152,7 +152,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
user->Length = user->MaximumLength - sizeof(WCHAR); user->Length = user->MaximumLength - sizeof(WCHAR);
if (!GetUserNameW(user->Buffer, &user_size)) if (!GetUserNameW(user->Buffer, &user_size))
{ {
heap_free(user); free(user);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
...@@ -165,14 +165,14 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma ...@@ -165,14 +165,14 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
domain_size = ARRAY_SIZE(computer); domain_size = ARRAY_SIZE(computer);
if (!GetComputerNameW(computer, &domain_size)) if (!GetComputerNameW(computer, &domain_size))
{ {
heap_free(user); free(user);
return STATUS_UNSUCCESSFUL; return STATUS_UNSUCCESSFUL;
} }
domain = heap_alloc(sizeof(*domain) + (domain_size + 1) * sizeof(WCHAR)); domain = malloc(sizeof(*domain) + (domain_size + 1) * sizeof(WCHAR));
if (!domain) if (!domain)
{ {
heap_free(user); free(user);
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
...@@ -362,7 +362,7 @@ NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer) ...@@ -362,7 +362,7 @@ NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
{ {
TRACE("(%p)\n", Buffer); TRACE("(%p)\n", Buffer);
heap_free(Buffer); free(Buffer);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -497,22 +497,22 @@ NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count, ...@@ -497,22 +497,22 @@ NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
TRACE("mapped %lu out of %lu\n", mapped, count); TRACE("mapped %lu out of %lu\n", mapped, count);
size = sizeof(LSA_TRANSLATED_SID2) * count + sid_size_total; size = sizeof(LSA_TRANSLATED_SID2) * count + sid_size_total;
if (!(*sids = heap_alloc(size))) return STATUS_NO_MEMORY; if (!(*sids = malloc(size))) return STATUS_NO_MEMORY;
sid = (SID *)(*sids + count); sid = (SID *)(*sids + count);
/* use maximum domain count */ /* use maximum domain count */
if (!(*domains = heap_alloc(sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION)*count + if (!(*domains = malloc(sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION) * count +
sid_size_total + domainname_size_total*sizeof(WCHAR)))) sid_size_total + domainname_size_total * sizeof(WCHAR))))
{ {
heap_free(*sids); free(*sids);
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
(*domains)->Entries = 0; (*domains)->Entries = 0;
(*domains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*domains + sizeof(LSA_REFERENCED_DOMAIN_LIST)); (*domains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*domains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
domain_data = (char*)(*domains)->Domains + sizeof(LSA_TRUST_INFORMATION)*count; domain_data = (char*)(*domains)->Domains + sizeof(LSA_TRUST_INFORMATION)*count;
domain.Buffer = heap_alloc(domain_size_max*sizeof(WCHAR)); domain.Buffer = malloc(domain_size_max * sizeof(WCHAR));
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
domain.Length = domain_size_max*sizeof(WCHAR); domain.Length = domain_size_max*sizeof(WCHAR);
...@@ -541,7 +541,7 @@ NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count, ...@@ -541,7 +541,7 @@ NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
} }
} }
} }
heap_free(domain.Buffer); free(domain.Buffer);
if (mapped == count) return STATUS_SUCCESS; if (mapped == count) return STATUS_SUCCESS;
if (mapped > 0 && mapped < count) return STATUS_SOME_NOT_MAPPED; if (mapped > 0 && mapped < count) return STATUS_SOME_NOT_MAPPED;
...@@ -584,13 +584,13 @@ NTSTATUS WINAPI LsaLookupSids( ...@@ -584,13 +584,13 @@ NTSTATUS WINAPI LsaLookupSids(
/* this length does not include actual string length yet */ /* this length does not include actual string length yet */
name_fullsize = sizeof(LSA_TRANSLATED_NAME) * Count; name_fullsize = sizeof(LSA_TRANSLATED_NAME) * Count;
if (!(*Names = heap_alloc(name_fullsize))) return STATUS_NO_MEMORY; if (!(*Names = malloc(name_fullsize))) return STATUS_NO_MEMORY;
/* maximum count of stored domain infos is Count, allocate it like that cause really needed /* maximum count of stored domain infos is Count, allocate it like that cause really needed
count could only be computed after sid data is retrieved */ count could only be computed after sid data is retrieved */
domain_fullsize = sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION)*Count; domain_fullsize = sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION)*Count;
if (!(*ReferencedDomains = heap_alloc(domain_fullsize))) if (!(*ReferencedDomains = malloc(domain_fullsize)))
{ {
heap_free(*Names); free(*Names);
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
} }
(*ReferencedDomains)->Entries = 0; (*ReferencedDomains)->Entries = 0;
...@@ -633,7 +633,7 @@ NTSTATUS WINAPI LsaLookupSids( ...@@ -633,7 +633,7 @@ NTSTATUS WINAPI LsaLookupSids(
domain_fullsize += domain_size * sizeof(WCHAR); domain_fullsize += domain_size * sizeof(WCHAR);
/* get domain SID size too */ /* get domain SID size too */
name = heap_alloc(domain_size * sizeof(WCHAR)); name = malloc(domain_size * sizeof(WCHAR));
*name = 0; *name = 0;
LookupAccountSidW(NULL, Sids[i], NULL, &name_size, name, &domain_size, &use); LookupAccountSidW(NULL, Sids[i], NULL, &name_size, name, &domain_size, &use);
...@@ -644,7 +644,7 @@ NTSTATUS WINAPI LsaLookupSids( ...@@ -644,7 +644,7 @@ NTSTATUS WINAPI LsaLookupSids(
lookup_name(&domain, NULL, &sid_size, NULL, &domain_size, &use, &handled); lookup_name(&domain, NULL, &sid_size, NULL, &domain_size, &use, &handled);
domain_fullsize += sid_size; domain_fullsize += sid_size;
heap_free(name); free(name);
} }
else else
{ {
...@@ -665,10 +665,10 @@ NTSTATUS WINAPI LsaLookupSids( ...@@ -665,10 +665,10 @@ NTSTATUS WINAPI LsaLookupSids(
} }
/* now we have full length needed for both */ /* now we have full length needed for both */
*Names = heap_realloc(*Names, name_fullsize); *Names = realloc(*Names, name_fullsize);
name_buffer = (WCHAR*)((char*)*Names + sizeof(LSA_TRANSLATED_NAME)*Count); name_buffer = (WCHAR*)((char*)*Names + sizeof(LSA_TRANSLATED_NAME)*Count);
*ReferencedDomains = heap_realloc(*ReferencedDomains, domain_fullsize); *ReferencedDomains = realloc(*ReferencedDomains, domain_fullsize);
/* fix pointer after reallocation */ /* fix pointer after reallocation */
(*ReferencedDomains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*ReferencedDomains + sizeof(LSA_REFERENCED_DOMAIN_LIST)); (*ReferencedDomains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*ReferencedDomains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
domain_data = (char*)(*ReferencedDomains)->Domains + sizeof(LSA_TRUST_INFORMATION)*Count; domain_data = (char*)(*ReferencedDomains)->Domains + sizeof(LSA_TRUST_INFORMATION)*Count;
...@@ -697,13 +697,13 @@ NTSTATUS WINAPI LsaLookupSids( ...@@ -697,13 +697,13 @@ NTSTATUS WINAPI LsaLookupSids(
domain.MaximumLength = sizeof(WCHAR); domain.MaximumLength = sizeof(WCHAR);
} }
domain.Buffer = heap_alloc(domain.MaximumLength); domain.Buffer = malloc(domain.MaximumLength);
LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use); LookupAccountSidW(NULL, Sids[i], (*Names)[i].Name.Buffer, &name_size, domain.Buffer, &domain_size, &use);
(*Names)[i].Use = use; (*Names)[i].Use = use;
(*Names)[i].DomainIndex = lsa_reflist_add_domain(*ReferencedDomains, &domain, &domain_data); (*Names)[i].DomainIndex = lsa_reflist_add_domain(*ReferencedDomains, &domain, &domain_data);
heap_free(domain.Buffer); free(domain.Buffer);
} }
else if (ConvertSidToStringSidW(Sids[i], &strsid)) else if (ConvertSidToStringSidW(Sids[i], &strsid))
{ {
...@@ -813,7 +813,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( ...@@ -813,7 +813,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
{ {
case PolicyAuditEventsInformation: /* 2 */ case PolicyAuditEventsInformation: /* 2 */
{ {
PPOLICY_AUDIT_EVENTS_INFO p = heap_alloc_zero(sizeof(POLICY_AUDIT_EVENTS_INFO)); PPOLICY_AUDIT_EVENTS_INFO p = calloc(1, sizeof(POLICY_AUDIT_EVENTS_INFO));
p->AuditingMode = FALSE; /* no auditing */ p->AuditingMode = FALSE; /* no auditing */
*Buffer = p; *Buffer = p;
} }
...@@ -843,7 +843,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( ...@@ -843,7 +843,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
}; };
DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1; DWORD dwSize = MAX_COMPUTERNAME_LENGTH + 1;
struct di * xdi = heap_alloc_zero(sizeof(*xdi)); struct di * xdi = calloc(1, sizeof(*xdi));
xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR); xdi->info.DomainName.MaximumLength = dwSize * sizeof(WCHAR);
xdi->info.DomainName.Buffer = xdi->domain; xdi->info.DomainName.Buffer = xdi->domain;
...@@ -856,7 +856,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( ...@@ -856,7 +856,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
if (!ADVAPI_GetComputerSid(&xdi->sid)) if (!ADVAPI_GetComputerSid(&xdi->sid))
{ {
heap_free(xdi); free(xdi);
WARN("Computer SID not found\n"); WARN("Computer SID not found\n");
...@@ -889,7 +889,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy( ...@@ -889,7 +889,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
} computer_sid; } computer_sid;
DWORD dwSize; DWORD dwSize;
xdi = heap_alloc_zero(sizeof(*xdi)); xdi = calloc(1, sizeof(*xdi));
if (!xdi) return STATUS_NO_MEMORY; if (!xdi) return STATUS_NO_MEMORY;
dwSize = 256; dwSize = 256;
...@@ -1156,7 +1156,7 @@ NTSTATUS WINAPI LsaLookupPrivilegeName(LSA_HANDLE handle, LUID *luid, LSA_UNICOD ...@@ -1156,7 +1156,7 @@ NTSTATUS WINAPI LsaLookupPrivilegeName(LSA_HANDLE handle, LUID *luid, LSA_UNICOD
return STATUS_NO_SUCH_PRIVILEGE; return STATUS_NO_SUCH_PRIVILEGE;
length = lstrlenW(privnameW); length = lstrlenW(privnameW);
*name = heap_alloc(sizeof(**name) + (length + 1) * sizeof(WCHAR)); *name = malloc(sizeof(**name) + (length + 1) * sizeof(WCHAR));
if (!*name) if (!*name)
return STATUS_NO_MEMORY; return STATUS_NO_MEMORY;
......
...@@ -79,7 +79,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST ...@@ -79,7 +79,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST
} }
sz = max( 2 * size, sizeof(*servicesW) ); sz = max( 2 * size, sizeof(*servicesW) );
if (!(servicesW = heap_alloc( sz ))) if (!(servicesW = malloc( sz )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
...@@ -113,7 +113,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST ...@@ -113,7 +113,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST
ret = TRUE; ret = TRUE;
done: done:
heap_free( servicesW ); free( servicesW );
return ret; return ret;
} }
...@@ -150,7 +150,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST ...@@ -150,7 +150,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
&& GetLastError() != ERROR_MORE_DATA) && GetLastError() != ERROR_MORE_DATA)
return FALSE; return FALSE;
if (!(status_ex = heap_alloc( alloc_size ))) if (!(status_ex = malloc( alloc_size )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
...@@ -160,7 +160,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST ...@@ -160,7 +160,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
alloc_size, &alloc_size, &count, resume_handle, NULL ) alloc_size, &alloc_size, &count, resume_handle, NULL )
&& GetLastError() != ERROR_MORE_DATA) && GetLastError() != ERROR_MORE_DATA)
{ {
heap_free( status_ex ); free( status_ex );
return FALSE; return FALSE;
} }
...@@ -198,7 +198,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST ...@@ -198,7 +198,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
status[i].ServiceStatus.dwWaitHint = status_ex[i].ServiceStatusProcess.dwWaitHint; status[i].ServiceStatus.dwWaitHint = status_ex[i].ServiceStatusProcess.dwWaitHint;
} }
heap_free( status_ex ); free( status_ex );
if (*ret_size > size) if (*ret_size > size)
{ {
SetLastError( ERROR_MORE_DATA ); SetLastError( ERROR_MORE_DATA );
...@@ -229,7 +229,7 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st ...@@ -229,7 +229,7 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
size, needed, returned, resume_handle, debugstr_a(group)); size, needed, returned, resume_handle, debugstr_a(group));
sz = max( 2 * size, sizeof(*servicesW) ); sz = max( 2 * size, sizeof(*servicesW) );
if (!(servicesW = heap_alloc( sz ))) if (!(servicesW = malloc( sz )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE; return FALSE;
...@@ -237,10 +237,10 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st ...@@ -237,10 +237,10 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
if (group) if (group)
{ {
int len = MultiByteToWideChar( CP_ACP, 0, group, -1, NULL, 0 ); int len = MultiByteToWideChar( CP_ACP, 0, group, -1, NULL, 0 );
if (!(groupW = heap_alloc( len * sizeof(WCHAR) ))) if (!(groupW = malloc( len * sizeof(WCHAR) )))
{ {
SetLastError( ERROR_NOT_ENOUGH_MEMORY ); SetLastError( ERROR_NOT_ENOUGH_MEMORY );
heap_free( servicesW ); free( servicesW );
return FALSE; return FALSE;
} }
MultiByteToWideChar( CP_ACP, 0, group, -1, groupW, len * sizeof(WCHAR) ); MultiByteToWideChar( CP_ACP, 0, group, -1, groupW, len * sizeof(WCHAR) );
...@@ -275,8 +275,8 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st ...@@ -275,8 +275,8 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
ret = TRUE; ret = TRUE;
done: done:
heap_free( servicesW ); free( servicesW );
heap_free( groupW ); free( groupW );
return ret; return ret;
} }
...@@ -295,7 +295,7 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName, ...@@ -295,7 +295,7 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName,
lpDisplayNameW = strdupAW(lpDisplayName); lpDisplayNameW = strdupAW(lpDisplayName);
if (lpServiceName) if (lpServiceName)
lpServiceNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR)); lpServiceNameW = malloc(*lpcchBuffer * sizeof(WCHAR));
else else
lpServiceNameW = NULL; lpServiceNameW = NULL;
...@@ -321,8 +321,8 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName, ...@@ -321,8 +321,8 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName,
ret = TRUE; ret = TRUE;
cleanup: cleanup:
heap_free(lpServiceNameW); free(lpServiceNameW);
heap_free(lpDisplayNameW); free(lpDisplayNameW);
return ret; return ret;
} }
...@@ -365,7 +365,7 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName, ...@@ -365,7 +365,7 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
lpServiceNameW = strdupAW(lpServiceName); lpServiceNameW = strdupAW(lpServiceName);
if (lpDisplayName) if (lpDisplayName)
lpDisplayNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR)); lpDisplayNameW = malloc(*lpcchBuffer * sizeof(WCHAR));
else else
lpDisplayNameW = NULL; lpDisplayNameW = NULL;
...@@ -392,8 +392,8 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName, ...@@ -392,8 +392,8 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
ret = TRUE; ret = TRUE;
cleanup: cleanup:
heap_free(lpDisplayNameW); free(lpDisplayNameW);
heap_free(lpServiceNameW); free(lpServiceNameW);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment