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
ret = LogonUserW( usernameW, domainW, passwordW, dwLogonType, dwLogonProvider, phToken );
done:
heap_free( usernameW );
heap_free( domainW );
heap_free( passwordW );
free( usernameW );
free( domainW );
free( passwordW );
return ret;
}
......
......@@ -23,7 +23,6 @@
#include "ntsecapi.h"
#include "winsvc.h"
#include "winnls.h"
#include "wine/heap.h"
const char * debugstr_sid(PSID sid);
BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName);
......@@ -41,7 +40,7 @@ static inline WCHAR *strdupAW( const char *src )
if (src)
{
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;
}
......
......@@ -229,7 +229,7 @@ static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type,
key.Length = key.MaximumLength = KEY_SIZE;
key.Buffer = (unsigned char *)key_data;
encrypted_credential_blob = heap_alloc(credential_blob_size);
encrypted_credential_blob = malloc(credential_blob_size);
if (!encrypted_credential_blob) return ERROR_OUTOFMEMORY;
memcpy(encrypted_credential_blob, credential_blob, credential_blob_size);
......@@ -238,7 +238,7 @@ static DWORD write_credential_blob(HKEY hkey, LPCWSTR target_name, DWORD type,
SystemFunction032(&data, &key);
ret = RegSetValueExW(hkey, L"Password", 0, REG_BINARY, encrypted_credential_blob, credential_blob_size);
heap_free(encrypted_credential_blob);
free(encrypted_credential_blob);
return ret;
}
......@@ -320,7 +320,7 @@ static DWORD host_write_credential( const CREDENTIALW *credential, BOOL preserve
size = sizeof(*cred) + (lstrlenW( credential->TargetName ) + lstrlenW( credential->UserName ) + 2) * sizeof(WCHAR);
size += credential->CredentialBlobSize;
if (credential->Comment) size += (lstrlenW( credential->Comment ) + 1) * sizeof(WCHAR);
if (!(cred = heap_alloc( size )))
if (!(cred = malloc( size )))
{
CloseHandle( mgr );
return ERROR_OUTOFMEMORY;
......@@ -356,7 +356,7 @@ static DWORD host_write_credential( const CREDENTIALW *credential, BOOL preserve
else cred->comment_size = 0;
ret = DeviceIoControl( mgr, IOCTL_MOUNTMGR_WRITE_CREDENTIAL, cred, size, NULL, 0, NULL, NULL );
heap_free( cred );
free( cred );
CloseHandle( mgr );
return ret ? ERROR_SUCCESS : GetLastError();
......@@ -435,7 +435,7 @@ static LPWSTR get_key_name_for_target(LPCWSTR target_name, DWORD type)
len += ARRAY_SIZE(L"DomPasswd: ");
}
key_name = heap_alloc(len * sizeof(WCHAR));
key_name = malloc(len * sizeof(WCHAR));
if (!key_name) return NULL;
lstrcpyW(key_name, prefix);
......@@ -463,13 +463,13 @@ static BOOL registry_credential_matches_filter(HKEY hkeyCred, LPCWSTR filter)
else if (type != REG_SZ)
return FALSE;
target_name = heap_alloc(count);
target_name = malloc(count);
if (!target_name)
return FALSE;
ret = RegQueryValueExW(hkeyCred, NULL, 0, &type, (LPVOID)target_name, &count);
if (ret != ERROR_SUCCESS || type != REG_SZ)
{
heap_free(target_name);
free(target_name);
return FALSE;
}
......@@ -481,7 +481,7 @@ static BOOL registry_credential_matches_filter(HKEY hkeyCred, LPCWSTR filter)
(p && !p[1] ? p - filter : -1), target_name,
(p && !p[1] ? p - filter : -1)) == CSTR_EQUAL;
heap_free(target_name);
free(target_name);
return ret;
}
......@@ -730,7 +730,7 @@ BOOL WINAPI CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags)
}
len = MultiByteToWideChar(CP_ACP, 0, TargetName, -1, NULL, 0);
TargetNameW = heap_alloc(len * sizeof(WCHAR));
TargetNameW = malloc(len * sizeof(WCHAR));
if (!TargetNameW)
{
SetLastError(ERROR_OUTOFMEMORY);
......@@ -740,7 +740,7 @@ BOOL WINAPI CredDeleteA(LPCSTR TargetName, DWORD Type, DWORD Flags)
ret = CredDeleteW(TargetNameW, Type, Flags);
heap_free(TargetNameW);
free(TargetNameW);
return ret;
}
......@@ -758,7 +758,7 @@ static DWORD host_delete_credential( const WCHAR *targetname )
if (mgr == INVALID_HANDLE_VALUE) return GetLastError();
size = sizeof(*cred) + name_size;
if (!(cred = heap_alloc( size )))
if (!(cred = malloc( size )))
{
CloseHandle( mgr );
return ERROR_OUTOFMEMORY;
......@@ -769,7 +769,7 @@ static DWORD host_delete_credential( const WCHAR *targetname )
lstrcpyW( ptr, targetname );
ret = DeviceIoControl( mgr, IOCTL_MOUNTMGR_DELETE_CREDENTIAL, cred, size, NULL, 0, NULL, NULL );
heap_free( cred );
free( cred );
CloseHandle( mgr );
return ret ? ERROR_SUCCESS : GetLastError();
......@@ -823,7 +823,7 @@ BOOL WINAPI CredDeleteW(LPCWSTR TargetName, DWORD Type, DWORD Flags)
key_name = get_key_name_for_target(TargetName, Type);
ret = RegDeleteKeyW(hkeyMgr, key_name);
heap_free(key_name);
free(key_name);
RegCloseKey(hkeyMgr);
if (ret != ERROR_SUCCESS)
{
......@@ -852,7 +852,7 @@ BOOL WINAPI CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count,
if (Filter)
{
len = MultiByteToWideChar(CP_ACP, 0, Filter, -1, NULL, 0);
FilterW = heap_alloc(len * sizeof(WCHAR));
FilterW = malloc(len * sizeof(WCHAR));
if (!FilterW)
{
SetLastError(ERROR_OUTOFMEMORY);
......@@ -865,16 +865,16 @@ BOOL WINAPI CredEnumerateA(LPCSTR Filter, DWORD Flags, DWORD *Count,
if (!CredEnumerateW(FilterW, Flags, Count, &CredentialsW))
{
heap_free(FilterW);
free(FilterW);
return FALSE;
}
heap_free(FilterW);
free(FilterW);
len = *Count * sizeof(PCREDENTIALA);
for (i = 0; i < *Count; i++)
len += convert_PCREDENTIALW_to_PCREDENTIALA(CredentialsW[i], NULL, 0);
*Credentials = heap_alloc(len);
*Credentials = malloc(len);
if (!*Credentials)
{
CredFree(CredentialsW);
......@@ -917,7 +917,7 @@ static DWORD host_enumerate_credentials( const WCHAR *filter, CREDENTIALW **cred
if (mgr == INVALID_HANDLE_VALUE) return GetLastError();
size = FIELD_OFFSET( struct mountmgr_credential_list, creds[CRED_LIST_COUNT] ) + filter_size + CRED_DATA_SIZE;
if (!(list = heap_alloc( size )))
if (!(list = malloc( size )))
{
CloseHandle( mgr );
return ERROR_OUTOFMEMORY;
......@@ -934,7 +934,7 @@ static DWORD host_enumerate_credentials( const WCHAR *filter, CREDENTIALW **cred
if ((ret = GetLastError()) != ERROR_MORE_DATA) goto done;
size = list->size + filter_size;
if (!(tmp = heap_realloc( list, size )))
if (!(tmp = realloc( list, size )))
{
ret = ERROR_OUTOFMEMORY;
goto done;
......@@ -994,7 +994,7 @@ static DWORD host_enumerate_credentials( const WCHAR *filter, CREDENTIALW **cred
ret = ERROR_SUCCESS;
done:
heap_free( list );
free( list );
CloseHandle( mgr );
return ret;
}
......@@ -1044,7 +1044,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
return FALSE;
}
target_name = heap_alloc((target_name_len+1)*sizeof(WCHAR));
target_name = malloc((target_name_len + 1) * sizeof(WCHAR));
if (!target_name)
{
RegCloseKey(hkeyMgr);
......@@ -1065,7 +1065,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
ret = ERROR_NOT_FOUND;
if (ret != ERROR_SUCCESS)
{
heap_free(target_name);
free(target_name);
RegCloseKey(hkeyMgr);
SetLastError(ret);
return FALSE;
......@@ -1074,7 +1074,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
if (ret == ERROR_SUCCESS)
{
buffer = heap_alloc(len);
buffer = malloc(len);
*Credentials = (PCREDENTIALW *)buffer;
if (buffer)
{
......@@ -1091,7 +1091,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
else ret = ERROR_OUTOFMEMORY;
}
heap_free(target_name);
free(target_name);
RegCloseKey(hkeyMgr);
if (ret != ERROR_SUCCESS)
......@@ -1107,7 +1107,7 @@ BOOL WINAPI CredEnumerateW(LPCWSTR Filter, DWORD Flags, DWORD *Count, PCREDENTIA
*/
VOID WINAPI CredFree(PVOID Buffer)
{
heap_free(Buffer);
free(Buffer);
}
/******************************************************************************
......@@ -1128,7 +1128,7 @@ BOOL WINAPI CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA *
}
len = MultiByteToWideChar(CP_ACP, 0, TargetName, -1, NULL, 0);
TargetNameW = heap_alloc(len * sizeof(WCHAR));
TargetNameW = malloc(len * sizeof(WCHAR));
if (!TargetNameW)
{
SetLastError(ERROR_OUTOFMEMORY);
......@@ -1138,13 +1138,13 @@ BOOL WINAPI CredReadA(LPCSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALA *
if (!CredReadW(TargetNameW, Type, Flags, &CredentialW))
{
heap_free(TargetNameW);
free(TargetNameW);
return FALSE;
}
heap_free(TargetNameW);
free(TargetNameW);
len = convert_PCREDENTIALW_to_PCREDENTIALA(CredentialW, NULL, 0);
*Credential = heap_alloc(len);
*Credential = malloc(len);
if (!*Credential)
{
SetLastError(ERROR_OUTOFMEMORY);
......@@ -1170,7 +1170,7 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
if (mgr == INVALID_HANDLE_VALUE) return GetLastError();
size_in = sizeof(*cred_in) + size_name;
if (!(cred_in = heap_alloc( size_in )))
if (!(cred_in = malloc( size_in )))
{
CloseHandle( mgr );
return ERROR_OUTOFMEMORY;
......@@ -1181,14 +1181,14 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
lstrcpyW( ptr, targetname );
size_out = 256;
if (!(cred_out = heap_alloc( size_out ))) goto done;
if (!(cred_out = malloc( size_out ))) goto done;
for (;;)
{
ret = DeviceIoControl( mgr, IOCTL_MOUNTMGR_READ_CREDENTIAL, cred_in, size_in, cred_out, size_out, NULL, NULL );
if (ret || (err = GetLastError()) != ERROR_MORE_DATA) break;
size_out *= 2;
if (!(tmp = heap_realloc( cred_out, size_out ))) goto done;
if (!(tmp = realloc( cred_out, size_out ))) goto done;
cred_out = tmp;
}
......@@ -1198,7 +1198,7 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
DWORD size = sizeof(*credential) + cred_out->targetname_size + cred_out->username_size + cred_out->comment_size +
cred_out->blob_size;
if (!(credential = heap_alloc_zero( size )))
if (!(credential = calloc( 1, size )))
{
err = ERROR_OUTOFMEMORY;
goto done;
......@@ -1231,8 +1231,8 @@ static DWORD host_read_credential( const WCHAR *targetname, CREDENTIALW **ret_cr
}
done:
heap_free( cred_in );
heap_free( cred_out );
free( cred_in );
free( cred_out );
CloseHandle( mgr );
return err;
}
......@@ -1300,7 +1300,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW
key_name = get_key_name_for_target(TargetName, Type);
ret = RegOpenKeyExW(hkeyMgr, key_name, 0, KEY_QUERY_VALUE, &hkeyCred);
heap_free(key_name);
free(key_name);
if (ret != ERROR_SUCCESS)
{
TRACE("credentials for target name %s not found\n", debugstr_w(TargetName));
......@@ -1312,7 +1312,7 @@ BOOL WINAPI CredReadW(LPCWSTR TargetName, DWORD Type, DWORD Flags, PCREDENTIALW
ret = registry_read_credential(hkeyCred, NULL, key_data, NULL, &len);
if (ret == ERROR_SUCCESS)
{
*Credential = heap_alloc(len);
*Credential = malloc(len);
if (*Credential)
{
len = sizeof(**Credential);
......@@ -1375,7 +1375,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf
if (TargetInformation->PackageName)
len += MultiByteToWideChar(CP_ACP, 0, TargetInformation->PackageName, -1, NULL, 0) * sizeof(WCHAR);
TargetInformationW = heap_alloc(len);
TargetInformationW = malloc(len);
if (!TargetInformationW)
{
SetLastError(ERROR_OUTOFMEMORY);
......@@ -1446,7 +1446,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf
ret = CredReadDomainCredentialsW(TargetInformationW, Flags, Size, &CredentialsW);
heap_free(TargetInformationW);
free(TargetInformationW);
if (ret)
{
......@@ -1457,7 +1457,7 @@ BOOL WINAPI CredReadDomainCredentialsA(PCREDENTIAL_TARGET_INFORMATIONA TargetInf
for (i = 0; i < *Size; i++)
len += convert_PCREDENTIALW_to_PCREDENTIALA(CredentialsW[i], NULL, 0);
*Credentials = heap_alloc(len);
*Credentials = malloc(len);
if (!*Credentials)
{
CredFree(CredentialsW);
......@@ -1519,7 +1519,7 @@ BOOL WINAPI CredWriteA(PCREDENTIALA Credential, DWORD Flags)
}
len = convert_PCREDENTIALA_to_PCREDENTIALW(Credential, NULL, 0);
CredentialW = heap_alloc(len);
CredentialW = malloc(len);
if (!CredentialW)
{
SetLastError(ERROR_OUTOFMEMORY);
......@@ -1530,7 +1530,7 @@ BOOL WINAPI CredWriteA(PCREDENTIALA Credential, DWORD Flags)
ret = CredWriteW(CredentialW, Flags);
heap_free(CredentialW);
free(CredentialW);
return ret;
}
......@@ -1621,7 +1621,7 @@ BOOL WINAPI CredWriteW(PCREDENTIALW Credential, DWORD Flags)
ret = RegCreateKeyExW(hkeyMgr, key_name, 0, NULL,
Credential->Persist == CRED_PERSIST_SESSION ? REG_OPTION_VOLATILE : REG_OPTION_NON_VOLATILE,
KEY_READ|KEY_WRITE, NULL, &hkeyCred, NULL);
heap_free(key_name);
free(key_name);
if (ret != ERROR_SUCCESS)
{
TRACE("credentials for target name %s not found\n",
......@@ -1677,13 +1677,13 @@ BOOL WINAPI CredMarshalCredentialA( CRED_MARSHAL_TYPE type, PVOID cred, LPSTR *o
if ((ret = CredMarshalCredentialW( type, cred, &outW )))
{
int len = WideCharToMultiByte( CP_ACP, 0, outW, -1, NULL, 0, NULL, NULL );
if (!(*out = heap_alloc( len )))
if (!(*out = malloc( len )))
{
heap_free( outW );
free( outW );
return FALSE;
}
WideCharToMultiByte( CP_ACP, 0, outW, -1, *out, len, NULL, NULL );
heap_free( outW );
free( outW );
}
return ret;
}
......@@ -1741,7 +1741,7 @@ BOOL WINAPI CredMarshalCredentialW( CRED_MARSHAL_TYPE type, PVOID cred, LPWSTR *
case CertCredential:
{
size = (sizeof(cert->rgbHashOfCert) + 2) * 4 / 3;
if (!(p = heap_alloc( (size + 4) * sizeof(WCHAR) ))) return FALSE;
if (!(p = malloc( (size + 4) * sizeof(WCHAR) ))) return FALSE;
p[0] = '@';
p[1] = '@';
p[2] = 'A' + type;
......@@ -1753,7 +1753,7 @@ BOOL WINAPI CredMarshalCredentialW( CRED_MARSHAL_TYPE type, PVOID cred, LPWSTR *
{
len = lstrlenW( target->UserName );
size = (sizeof(DWORD) + len * sizeof(WCHAR) + 2) * 4 / 3;
if (!(p = heap_alloc( (size + 4) * sizeof(WCHAR) ))) return FALSE;
if (!(p = malloc( (size + 4) * sizeof(WCHAR) ))) return FALSE;
p[0] = '@';
p[1] = '@';
p[2] = 'A' + type;
......@@ -1786,11 +1786,11 @@ BOOL WINAPI CredUnmarshalCredentialA( LPCSTR cred, PCRED_MARSHAL_TYPE type, PVOI
if (cred)
{
int len = MultiByteToWideChar( CP_ACP, 0, cred, -1, NULL, 0 );
if (!(credW = heap_alloc( len * sizeof(WCHAR) ))) return FALSE;
if (!(credW = malloc( len * sizeof(WCHAR) ))) return FALSE;
MultiByteToWideChar( CP_ACP, 0, cred, -1, credW, len );
}
ret = CredUnmarshalCredentialW( credW, type, out );
heap_free( credW );
free( credW );
return ret;
}
......@@ -1876,7 +1876,7 @@ BOOL WINAPI CredUnmarshalCredentialW( LPCWSTR cred, PCRED_MARSHAL_TYPE type, PVO
SetLastError( ERROR_INVALID_PARAMETER );
return FALSE;
}
if (!(cert = heap_alloc( sizeof(*cert) ))) return FALSE;
if (!(cert = malloc( sizeof(*cert) ))) return FALSE;
memcpy( cert->rgbHashOfCert, hash, sizeof(cert->rgbHashOfCert) );
cert->cbSize = sizeof(*cert);
*out = cert;
......@@ -1894,10 +1894,10 @@ BOOL WINAPI CredUnmarshalCredentialW( LPCWSTR cred, PCRED_MARSHAL_TYPE type, PVO
return FALSE;
}
buflen = sizeof(*target) + size + sizeof(WCHAR);
if (!(target = heap_alloc( buflen ))) return FALSE;
if (!(target = malloc( buflen ))) return FALSE;
if (!cred_decode( cred + 9, len - 6, (char *)(target + 1) ))
{
heap_free( target );
free( target );
return FALSE;
}
target->UserName = (WCHAR *)(target + 1);
......@@ -1973,11 +1973,11 @@ BOOL WINAPI CredIsMarshaledCredentialA(LPCSTR name)
if (name)
{
len = MultiByteToWideChar(CP_ACP, 0, name, -1, NULL, 0);
nameW = heap_alloc(len * sizeof(WCHAR));
nameW = malloc(len * sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, name, -1, nameW, len);
}
res = CredIsMarshaledCredentialW(nameW);
heap_free(nameW);
free(nameW);
return res;
}
......@@ -58,7 +58,7 @@ BOOL WINAPI BackupEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
backupW = strdupAW(lpBackupFileName);
ret = BackupEventLogW(hEventLog, backupW);
heap_free(backupW);
free(backupW);
return ret;
}
......@@ -115,7 +115,7 @@ BOOL WINAPI ClearEventLogA( HANDLE hEventLog, LPCSTR lpBackupFileName )
backupW = strdupAW(lpBackupFileName);
ret = ClearEventLogW(hEventLog, backupW);
heap_free(backupW);
free(backupW);
return ret;
}
......@@ -394,8 +394,8 @@ HANDLE WINAPI OpenBackupEventLogA( LPCSTR lpUNCServerName, LPCSTR lpFileName )
uncnameW = strdupAW(lpUNCServerName);
filenameW = strdupAW(lpFileName);
handle = OpenBackupEventLogW(uncnameW, filenameW);
heap_free(uncnameW);
heap_free(filenameW);
free(uncnameW);
free(filenameW);
return handle;
}
......@@ -453,8 +453,8 @@ HANDLE WINAPI OpenEventLogA( LPCSTR uncname, LPCSTR source )
uncnameW = strdupAW(uncname);
sourceW = strdupAW(source);
handle = OpenEventLogW(uncnameW, sourceW);
heap_free(uncnameW);
heap_free(sourceW);
free(uncnameW);
free(sourceW);
return handle;
}
......@@ -608,7 +608,7 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d
if (wNumStrings == 0) return TRUE;
if (!lpStrings) return TRUE;
wideStrArray = heap_alloc(sizeof(LPWSTR) * wNumStrings);
wideStrArray = malloc(sizeof(WCHAR *) * wNumStrings);
for (i = 0; i < wNumStrings; i++)
{
RtlCreateUnicodeStringFromAsciiz(&str, lpStrings[i]);
......@@ -617,8 +617,8 @@ BOOL WINAPI ReportEventA ( HANDLE hEventLog, WORD wType, WORD wCategory, DWORD d
ret = ReportEventW(hEventLog, wType, wCategory, dwEventID, lpUserSid,
wNumStrings, dwDataSize, (LPCWSTR *)wideStrArray, lpRawData);
for (i = 0; i < wNumStrings; i++)
heap_free( wideStrArray[i] );
heap_free(wideStrArray);
free(wideStrArray[i]);
free(wideStrArray);
return ret;
}
......
......@@ -103,7 +103,7 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, NULL, &size);
if (ret == ERROR_MORE_DATA || ret == ERROR_SUCCESS)
{
ptr = heap_alloc_zero(sz + size);
ptr = calloc(1, sz + size);
if (!ptr) return NULL;
ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = size;
......@@ -111,16 +111,16 @@ static void* ADVAPI_GetDomainName(unsigned sz, unsigned ofs)
ret = RegQueryValueExW(key, L"Workgroup", NULL, NULL, (LPBYTE)ustr->Buffer, &size);
if (ret != ERROR_SUCCESS)
{
heap_free(ptr);
free(ptr);
ptr = NULL;
}
}
else ustr->Length = size - sizeof(WCHAR);
}
RegCloseKey(key);
}
if (!ptr)
{
ptr = heap_alloc_zero(sz + sizeof(L"DOMAIN"));
ptr = calloc(1, sz + sizeof(L"DOMAIN"));
if (!ptr) return NULL;
ustr = (UNICODE_STRING*)(ptr + ofs);
ustr->MaximumLength = sizeof(L"DOMAIN");
......@@ -144,7 +144,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
if (GetUserNameW(NULL, &user_size) || GetLastError() != ERROR_INSUFFICIENT_BUFFER)
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;
user->Buffer = (WCHAR *)(user + 1);
......@@ -152,7 +152,7 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
user->Length = user->MaximumLength - sizeof(WCHAR);
if (!GetUserNameW(user->Buffer, &user_size))
{
heap_free(user);
free(user);
return STATUS_UNSUCCESSFUL;
}
......@@ -165,14 +165,14 @@ NTSTATUS WINAPI LsaGetUserName(PUNICODE_STRING *user_name, PUNICODE_STRING *doma
domain_size = ARRAY_SIZE(computer);
if (!GetComputerNameW(computer, &domain_size))
{
heap_free(user);
free(user);
return STATUS_UNSUCCESSFUL;
}
domain = heap_alloc(sizeof(*domain) + (domain_size + 1) * sizeof(WCHAR));
domain = malloc(sizeof(*domain) + (domain_size + 1) * sizeof(WCHAR));
if (!domain)
{
heap_free(user);
free(user);
return STATUS_NO_MEMORY;
}
......@@ -362,7 +362,7 @@ NTSTATUS WINAPI LsaFreeMemory(IN PVOID Buffer)
{
TRACE("(%p)\n", Buffer);
heap_free(Buffer);
free(Buffer);
return STATUS_SUCCESS;
}
......@@ -497,22 +497,22 @@ NTSTATUS WINAPI LsaLookupNames2( LSA_HANDLE policy, ULONG flags, ULONG count,
TRACE("mapped %lu out of %lu\n", mapped, count);
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);
/* use maximum domain count */
if (!(*domains = heap_alloc(sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION)*count +
sid_size_total + domainname_size_total*sizeof(WCHAR))))
if (!(*domains = malloc(sizeof(LSA_REFERENCED_DOMAIN_LIST) + sizeof(LSA_TRUST_INFORMATION) * count +
sid_size_total + domainname_size_total * sizeof(WCHAR))))
{
heap_free(*sids);
free(*sids);
return STATUS_NO_MEMORY;
}
(*domains)->Entries = 0;
(*domains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*domains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
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++)
{
domain.Length = domain_size_max*sizeof(WCHAR);
......@@ -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 > 0 && mapped < count) return STATUS_SOME_NOT_MAPPED;
......@@ -584,13 +584,13 @@ NTSTATUS WINAPI LsaLookupSids(
/* this length does not include actual string length yet */
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
count could only be computed after sid data is retrieved */
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;
}
(*ReferencedDomains)->Entries = 0;
......@@ -633,7 +633,7 @@ NTSTATUS WINAPI LsaLookupSids(
domain_fullsize += domain_size * sizeof(WCHAR);
/* get domain SID size too */
name = heap_alloc(domain_size * sizeof(WCHAR));
name = malloc(domain_size * sizeof(WCHAR));
*name = 0;
LookupAccountSidW(NULL, Sids[i], NULL, &name_size, name, &domain_size, &use);
......@@ -644,7 +644,7 @@ NTSTATUS WINAPI LsaLookupSids(
lookup_name(&domain, NULL, &sid_size, NULL, &domain_size, &use, &handled);
domain_fullsize += sid_size;
heap_free(name);
free(name);
}
else
{
......@@ -665,10 +665,10 @@ NTSTATUS WINAPI LsaLookupSids(
}
/* 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);
*ReferencedDomains = heap_realloc(*ReferencedDomains, domain_fullsize);
*ReferencedDomains = realloc(*ReferencedDomains, domain_fullsize);
/* fix pointer after reallocation */
(*ReferencedDomains)->Domains = (LSA_TRUST_INFORMATION*)((char*)*ReferencedDomains + sizeof(LSA_REFERENCED_DOMAIN_LIST));
domain_data = (char*)(*ReferencedDomains)->Domains + sizeof(LSA_TRUST_INFORMATION)*Count;
......@@ -697,13 +697,13 @@ NTSTATUS WINAPI LsaLookupSids(
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);
(*Names)[i].Use = use;
(*Names)[i].DomainIndex = lsa_reflist_add_domain(*ReferencedDomains, &domain, &domain_data);
heap_free(domain.Buffer);
free(domain.Buffer);
}
else if (ConvertSidToStringSidW(Sids[i], &strsid))
{
......@@ -813,7 +813,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
{
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 */
*Buffer = p;
}
......@@ -843,7 +843,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
};
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.Buffer = xdi->domain;
......@@ -856,7 +856,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
if (!ADVAPI_GetComputerSid(&xdi->sid))
{
heap_free(xdi);
free(xdi);
WARN("Computer SID not found\n");
......@@ -889,7 +889,7 @@ NTSTATUS WINAPI LsaQueryInformationPolicy(
} computer_sid;
DWORD dwSize;
xdi = heap_alloc_zero(sizeof(*xdi));
xdi = calloc(1, sizeof(*xdi));
if (!xdi) return STATUS_NO_MEMORY;
dwSize = 256;
......@@ -1156,7 +1156,7 @@ NTSTATUS WINAPI LsaLookupPrivilegeName(LSA_HANDLE handle, LUID *luid, LSA_UNICOD
return STATUS_NO_SUCH_PRIVILEGE;
length = lstrlenW(privnameW);
*name = heap_alloc(sizeof(**name) + (length + 1) * sizeof(WCHAR));
*name = malloc(sizeof(**name) + (length + 1) * sizeof(WCHAR));
if (!*name)
return STATUS_NO_MEMORY;
......
......@@ -234,12 +234,12 @@ BOOL ADVAPI_IsLocalComputer(LPCWSTR ServerName)
if (!ServerName || !ServerName[0])
return TRUE;
buf = heap_alloc(dwSize * sizeof(WCHAR));
buf = malloc(dwSize * sizeof(WCHAR));
Result = GetComputerNameW(buf, &dwSize);
if (Result && (ServerName[0] == '\\') && (ServerName[1] == '\\'))
ServerName += 2;
Result = Result && !wcscmp(ServerName, buf);
heap_free(buf);
free(buf);
return Result;
}
......@@ -599,7 +599,7 @@ LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName,
ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, NULL, &wLen);
if (!ret && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
LPWSTR lpNameW = heap_alloc(wLen * sizeof(WCHAR));
LPWSTR lpNameW = malloc(wLen * sizeof(WCHAR));
ret = LookupPrivilegeNameW(lpSystemNameW.Buffer, lpLuid, lpNameW,
&wLen);
......@@ -628,7 +628,7 @@ LookupPrivilegeNameA( LPCSTR lpSystemName, PLUID lpLuid, LPSTR lpName,
*cchName = len - 1;
}
}
heap_free(lpNameW);
free(lpNameW);
}
RtlFreeUnicodeString(&lpSystemNameW);
return ret;
......@@ -726,7 +726,7 @@ GetFileSecurityA( LPCSTR lpFileName,
name = strdupAW(lpFileName);
r = GetFileSecurityW( name, RequestedInformation, pSecurityDescriptor,
nLength, lpnLengthNeeded );
heap_free( name );
free( name );
return r;
}
......@@ -754,9 +754,9 @@ LookupAccountSidA(
systemW = strdupAW(system);
if (account)
accountW = heap_alloc( accountSizeW * sizeof(WCHAR) );
accountW = malloc( accountSizeW * sizeof(WCHAR) );
if (domain)
domainW = heap_alloc( domainSizeW * sizeof(WCHAR) );
domainW = malloc( domainSizeW * sizeof(WCHAR) );
r = LookupAccountSidW( systemW, sid, accountW, &accountSizeW, domainW, &domainSizeW, name_use );
......@@ -781,9 +781,9 @@ LookupAccountSidA(
*domainSize = domainSizeW + 1;
}
heap_free( systemW );
heap_free( accountW );
heap_free( domainW );
free( systemW );
free( accountW );
free( domainW );
return r;
}
......@@ -867,7 +867,7 @@ LookupAccountSidW(
DWORD size = MAX_COMPUTERNAME_LENGTH + 1;
BOOL result;
computer_name = heap_alloc(size * sizeof(WCHAR));
computer_name = malloc(size * sizeof(WCHAR));
result = GetComputerNameW(computer_name, &size);
if (result) {
......@@ -921,7 +921,7 @@ LookupAccountSidW(
break;
case 1000: /* first user account */
size = UNLEN + 1;
account_name = heap_alloc(size * sizeof(WCHAR));
account_name = malloc(size * sizeof(WCHAR));
if (GetUserNameW(account_name, &size))
ac = account_name;
else
......@@ -968,14 +968,14 @@ LookupAccountSidW(
else
*accountSize = ac_len + 1;
heap_free(account_name);
heap_free(computer_name);
free(account_name);
free(computer_name);
if (status) *name_use = use;
return status;
}
heap_free(account_name);
heap_free(computer_name);
free(account_name);
free(computer_name);
SetLastError(ERROR_NONE_MAPPED);
return FALSE;
}
......@@ -1009,7 +1009,7 @@ BOOL WINAPI SetFileSecurityA( LPCSTR lpFileName,
name = strdupAW(lpFileName);
r = SetFileSecurityW( name, RequestedInformation, pSecurityDescriptor );
heap_free( name );
free( name );
return r;
}
......@@ -1079,7 +1079,7 @@ LookupAccountNameA(
RtlCreateUnicodeStringFromAsciiz(&lpAccountW, account);
if (ReferencedDomainName)
lpReferencedDomainNameW = heap_alloc(*cbReferencedDomainName * sizeof(WCHAR));
lpReferencedDomainNameW = malloc(*cbReferencedDomainName * sizeof(WCHAR));
ret = LookupAccountNameW(lpSystemW.Buffer, lpAccountW.Buffer, sid, cbSid, lpReferencedDomainNameW,
cbReferencedDomainName, name_use);
......@@ -1092,7 +1092,7 @@ LookupAccountNameA(
RtlFreeUnicodeString(&lpSystemW);
RtlFreeUnicodeString(&lpAccountW);
heap_free(lpReferencedDomainNameW);
free(lpReferencedDomainNameW);
return ret;
}
......@@ -1279,7 +1279,7 @@ BOOL lookup_local_wellknown_name( const LSA_UNICODE_STRING *account_and_domain,
{
DWORD len, sidLen = SECURITY_MAX_SID_SIZE;
if (!(pSid = heap_alloc( sidLen ))) return FALSE;
if (!(pSid = malloc( sidLen ))) return FALSE;
if ((ret = CreateWellKnownSid( ACCOUNT_SIDS[i].type, NULL, pSid, &sidLen )))
{
......@@ -1311,7 +1311,7 @@ BOOL lookup_local_wellknown_name( const LSA_UNICODE_STRING *account_and_domain,
if (ret)
*peUse = ACCOUNT_SIDS[i].name_use;
heap_free(pSid);
free(pSid);
*handled = TRUE;
return ret;
}
......@@ -1336,7 +1336,7 @@ BOOL lookup_local_user_name( const LSA_UNICODE_STRING *account_and_domain,
/* Let the current Unix user id masquerade as first Windows user account */
nameLen = UNLEN + 1;
if (!(userName = heap_alloc( nameLen * sizeof(WCHAR) ))) return FALSE;
if (!(userName = malloc( nameLen * sizeof(WCHAR) ))) return FALSE;
if (domain.Buffer)
{
......@@ -1367,7 +1367,7 @@ BOOL lookup_local_user_name( const LSA_UNICODE_STRING *account_and_domain,
}
}
heap_free(userName);
free(userName);
return ret;
}
......@@ -1975,7 +1975,7 @@ static DWORD trustee_name_A_to_W(TRUSTEE_FORM form, char *trustee_nameA, WCHAR *
if (objA)
{
if (!(objW = heap_alloc( sizeof(OBJECTS_AND_NAME_W) )))
if (!(objW = malloc( sizeof(OBJECTS_AND_NAME_W) )))
return ERROR_NOT_ENOUGH_MEMORY;
objW->ObjectsPresent = objA->ObjectsPresent;
......@@ -2003,7 +2003,7 @@ static void free_trustee_name(TRUSTEE_FORM form, WCHAR *trustee_nameW)
switch (form)
{
case TRUSTEE_IS_NAME:
heap_free( trustee_nameW );
free( trustee_nameW );
break;
case TRUSTEE_IS_OBJECTS_AND_NAME:
{
......@@ -2011,10 +2011,10 @@ static void free_trustee_name(TRUSTEE_FORM form, WCHAR *trustee_nameW)
if (objW)
{
heap_free( objW->ptstrName );
heap_free( objW->InheritedObjectTypeName );
heap_free( objW->ObjectTypeName );
heap_free( objW );
free( objW->ptstrName );
free( objW->InheritedObjectTypeName );
free( objW->ObjectTypeName );
free( objW );
}
break;
......@@ -2093,7 +2093,7 @@ DWORD WINAPI SetEntriesInAclA( ULONG count, PEXPLICIT_ACCESSA pEntries,
if (!count && !OldAcl)
return ERROR_SUCCESS;
pEntriesW = heap_alloc( count * sizeof(EXPLICIT_ACCESSW) );
pEntriesW = malloc( count * sizeof(EXPLICIT_ACCESSW) );
if (!pEntriesW)
return ERROR_NOT_ENOUGH_MEMORY;
......@@ -2129,7 +2129,7 @@ cleanup:
for (free_index = 0; free_index < alloc_index; ++free_index)
free_trustee_name( pEntriesW[free_index].Trustee.TrusteeForm, pEntriesW[free_index].Trustee.ptstrName );
heap_free( pEntriesW );
free( pEntriesW );
return err;
}
......@@ -2154,7 +2154,7 @@ DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
return ERROR_SUCCESS;
/* allocate array of maximum sized sids allowed */
ppsid = heap_alloc(count * (sizeof(SID *) + FIELD_OFFSET(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES])));
ppsid = malloc(count * (sizeof(SID *) + FIELD_OFFSET(SID, SubAuthority[SID_MAX_SUB_AUTHORITIES])));
if (!ppsid)
return ERROR_OUTOFMEMORY;
......@@ -2344,7 +2344,7 @@ DWORD WINAPI SetEntriesInAclW( ULONG count, PEXPLICIT_ACCESSW pEntries,
}
exit:
heap_free(ppsid);
free(ppsid);
return ret;
}
......@@ -2365,7 +2365,7 @@ DWORD WINAPI SetNamedSecurityInfoA(LPSTR pObjectName,
r = SetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, psidOwner,
psidGroup, pDacl, pSacl );
heap_free( wstr );
free( wstr );
return r;
}
......@@ -2565,7 +2565,7 @@ BOOL WINAPI ConvertStringSecurityDescriptorToSecurityDescriptorA(
ret = ConvertStringSecurityDescriptorToSecurityDescriptorW(StringSecurityDescriptorW,
StringSDRevision, SecurityDescriptor,
SecurityDescriptorSize);
heap_free(StringSecurityDescriptorW);
free(StringSecurityDescriptorW);
return ret;
}
......@@ -2582,7 +2582,7 @@ BOOL WINAPI ConvertSecurityDescriptorToStringSecurityDescriptorA(PSECURITY_DESCR
int lenA;
lenA = WideCharToMultiByte(CP_ACP, 0, wstr, len, NULL, 0, NULL, NULL);
*OutputString = heap_alloc(lenA);
*OutputString = malloc(lenA);
WideCharToMultiByte(CP_ACP, 0, wstr, len, *OutputString, lenA, NULL, NULL);
LocalFree(wstr);
......@@ -2615,7 +2615,7 @@ BOOL WINAPI ConvertStringSidToSidA(LPCSTR StringSid, PSID* Sid)
{
WCHAR *wStringSid = strdupAW(StringSid);
bret = ConvertStringSidToSidW(wStringSid, Sid);
heap_free(wStringSid);
free(wStringSid);
}
return bret;
}
......@@ -2691,7 +2691,7 @@ DWORD WINAPI GetNamedSecurityInfoA(LPSTR pObjectName,
r = GetNamedSecurityInfoW( wstr, ObjectType, SecurityInfo, ppsidOwner,
ppsidGroup, ppDacl, ppSacl, ppSecurityDescriptor );
heap_free( wstr );
free( wstr );
return r;
}
......@@ -2852,14 +2852,14 @@ static NTSTATUS combine_dacls(ACL *parent, ACL *child, ACL **result)
int i;
/* initialize a combined DACL containing both inherited and new ACEs */
combined = heap_alloc_zero(child->AclSize+parent->AclSize);
combined = calloc(1, child->AclSize + parent->AclSize);
if (!combined)
return STATUS_NO_MEMORY;
status = RtlCreateAcl(combined, parent->AclSize+child->AclSize, ACL_REVISION);
if (status != STATUS_SUCCESS)
{
heap_free(combined);
free(combined);
return status;
}
......@@ -2934,19 +2934,19 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
if (status != STATUS_BUFFER_TOO_SMALL)
return RtlNtStatusToDosError(status);
psd = heap_alloc(size);
psd = malloc(size);
if (!psd)
return ERROR_NOT_ENOUGH_MEMORY;
status = NtQuerySecurityObject(handle, SecurityInfo, psd, size, &size);
if (status)
{
heap_free(psd);
free(psd);
return RtlNtStatusToDosError(status);
}
status = RtlGetControlSecurityDescriptor(psd, &control, &rev);
heap_free(psd);
free(psd);
if (status)
return RtlNtStatusToDosError(status);
/* TODO: copy some control flags to new sd */
......@@ -2958,14 +2958,14 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
if (status != STATUS_INFO_LENGTH_MISMATCH)
return RtlNtStatusToDosError(status);
name_info = heap_alloc(size);
name_info = malloc(size);
if (!name_info)
return ERROR_NOT_ENOUGH_MEMORY;
status = NtQueryObject(handle, ObjectNameInformation, name_info, size, NULL);
if (status)
{
heap_free(name_info);
free(name_info);
return RtlNtStatusToDosError(status);
}
......@@ -2992,7 +2992,7 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
status = NtOpenFile(&parent, READ_CONTROL|SYNCHRONIZE, &attr, &io,
FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE,
FILE_OPEN_FOR_BACKUP_INTENT);
heap_free(name_info);
free(name_info);
if (!status)
{
err = GetSecurityInfo(parent, SE_FILE_OBJECT, DACL_SECURITY_INFORMATION,
......@@ -3009,7 +3009,7 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
}
}
else
heap_free(name_info);
free(name_info);
}
}
......@@ -3029,7 +3029,7 @@ DWORD WINAPI SetSecurityInfo(HANDLE handle, SE_OBJECT_TYPE ObjectType,
break;
}
if (dacl != pDacl)
heap_free(dacl);
free(dacl);
return RtlNtStatusToDosError(status);
}
......
......@@ -79,7 +79,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST
}
sz = max( 2 * size, sizeof(*servicesW) );
if (!(servicesW = heap_alloc( sz )))
if (!(servicesW = malloc( sz )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
......@@ -113,7 +113,7 @@ EnumServicesStatusA( SC_HANDLE hmngr, DWORD type, DWORD state, LPENUM_SERVICE_ST
ret = TRUE;
done:
heap_free( servicesW );
free( servicesW );
return ret;
}
......@@ -150,7 +150,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
&& GetLastError() != ERROR_MORE_DATA)
return FALSE;
if (!(status_ex = heap_alloc( alloc_size )))
if (!(status_ex = malloc( alloc_size )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
......@@ -160,7 +160,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
alloc_size, &alloc_size, &count, resume_handle, NULL )
&& GetLastError() != ERROR_MORE_DATA)
{
heap_free( status_ex );
free( status_ex );
return FALSE;
}
......@@ -198,7 +198,7 @@ EnumServicesStatusW( SC_HANDLE manager, DWORD type, DWORD state, ENUM_SERVICE_ST
status[i].ServiceStatus.dwWaitHint = status_ex[i].ServiceStatusProcess.dwWaitHint;
}
heap_free( status_ex );
free( status_ex );
if (*ret_size > size)
{
SetLastError( ERROR_MORE_DATA );
......@@ -229,7 +229,7 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
size, needed, returned, resume_handle, debugstr_a(group));
sz = max( 2 * size, sizeof(*servicesW) );
if (!(servicesW = heap_alloc( sz )))
if (!(servicesW = malloc( sz )))
{
SetLastError( ERROR_NOT_ENOUGH_MEMORY );
return FALSE;
......@@ -237,10 +237,10 @@ EnumServicesStatusExA( SC_HANDLE hmngr, SC_ENUM_TYPE level, DWORD type, DWORD st
if (group)
{
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 );
heap_free( servicesW );
free( servicesW );
return FALSE;
}
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
ret = TRUE;
done:
heap_free( servicesW );
heap_free( groupW );
free( servicesW );
free( groupW );
return ret;
}
......@@ -295,7 +295,7 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName,
lpDisplayNameW = strdupAW(lpDisplayName);
if (lpServiceName)
lpServiceNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR));
lpServiceNameW = malloc(*lpcchBuffer * sizeof(WCHAR));
else
lpServiceNameW = NULL;
......@@ -321,8 +321,8 @@ BOOL WINAPI GetServiceKeyNameA( SC_HANDLE hSCManager, LPCSTR lpDisplayName,
ret = TRUE;
cleanup:
heap_free(lpServiceNameW);
heap_free(lpDisplayNameW);
free(lpServiceNameW);
free(lpDisplayNameW);
return ret;
}
......@@ -365,7 +365,7 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
lpServiceNameW = strdupAW(lpServiceName);
if (lpDisplayName)
lpDisplayNameW = heap_alloc(*lpcchBuffer * sizeof(WCHAR));
lpDisplayNameW = malloc(*lpcchBuffer * sizeof(WCHAR));
else
lpDisplayNameW = NULL;
......@@ -392,8 +392,8 @@ BOOL WINAPI GetServiceDisplayNameA( SC_HANDLE hSCManager, LPCSTR lpServiceName,
ret = TRUE;
cleanup:
heap_free(lpDisplayNameW);
heap_free(lpServiceNameW);
free(lpDisplayNameW);
free(lpServiceNameW);
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