Commit dd3f3f38 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

taskkill: Use CRT allocation functions.

parent 1210b98c
...@@ -58,13 +58,13 @@ static int taskkill_vprintfW(const WCHAR *msg, va_list va_args) ...@@ -58,13 +58,13 @@ static int taskkill_vprintfW(const WCHAR *msg, va_list va_args)
*/ */
len = WideCharToMultiByte(GetOEMCP(), 0, msg_buffer, wlen, len = WideCharToMultiByte(GetOEMCP(), 0, msg_buffer, wlen,
NULL, 0, NULL, NULL); NULL, 0, NULL, NULL);
msgA = HeapAlloc(GetProcessHeap(), 0, len); msgA = malloc(len);
if (!msgA) if (!msgA)
return 0; return 0;
WideCharToMultiByte(GetOEMCP(), 0, msg_buffer, wlen, msgA, len, NULL, NULL); WideCharToMultiByte(GetOEMCP(), 0, msg_buffer, wlen, msgA, len, NULL, NULL);
WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), msgA, len, &count, FALSE);
HeapFree(GetProcessHeap(), 0, msgA); free(msgA);
} }
return count; return count;
...@@ -127,7 +127,7 @@ static DWORD *enumerate_processes(DWORD *list_count) ...@@ -127,7 +127,7 @@ static DWORD *enumerate_processes(DWORD *list_count)
{ {
DWORD *pid_list, alloc_bytes = 1024 * sizeof(*pid_list), needed_bytes; DWORD *pid_list, alloc_bytes = 1024 * sizeof(*pid_list), needed_bytes;
pid_list = HeapAlloc(GetProcessHeap(), 0, alloc_bytes); pid_list = malloc(alloc_bytes);
if (!pid_list) if (!pid_list)
return NULL; return NULL;
...@@ -137,7 +137,7 @@ static DWORD *enumerate_processes(DWORD *list_count) ...@@ -137,7 +137,7 @@ static DWORD *enumerate_processes(DWORD *list_count)
if (!EnumProcesses(pid_list, alloc_bytes, &needed_bytes)) if (!EnumProcesses(pid_list, alloc_bytes, &needed_bytes))
{ {
HeapFree(GetProcessHeap(), 0, pid_list); free(pid_list);
return NULL; return NULL;
} }
...@@ -150,10 +150,10 @@ static DWORD *enumerate_processes(DWORD *list_count) ...@@ -150,10 +150,10 @@ static DWORD *enumerate_processes(DWORD *list_count)
break; break;
alloc_bytes *= 2; alloc_bytes *= 2;
realloc_list = HeapReAlloc(GetProcessHeap(), 0, pid_list, alloc_bytes); realloc_list = realloc(pid_list, alloc_bytes);
if (!realloc_list) if (!realloc_list)
{ {
HeapFree(GetProcessHeap(), 0, pid_list); free(pid_list);
return NULL; return NULL;
} }
pid_list = realloc_list; pid_list = realloc_list;
...@@ -288,7 +288,7 @@ static int send_close_messages(void) ...@@ -288,7 +288,7 @@ static int send_close_messages(void)
} }
} }
HeapFree(GetProcessHeap(), 0, pid_list); free(pid_list);
return status_code; return status_code;
} }
...@@ -403,7 +403,7 @@ static int terminate_processes(void) ...@@ -403,7 +403,7 @@ static int terminate_processes(void)
} }
} }
HeapFree(GetProcessHeap(), 0, pid_list); free(pid_list);
return status_code; return status_code;
} }
...@@ -413,8 +413,7 @@ static BOOL add_to_task_list(WCHAR *name) ...@@ -413,8 +413,7 @@ static BOOL add_to_task_list(WCHAR *name)
if (!task_list) if (!task_list)
{ {
task_list = HeapAlloc(GetProcessHeap(), 0, task_list = malloc(list_size * sizeof(*task_list));
list_size * sizeof(*task_list));
if (!task_list) if (!task_list)
return FALSE; return FALSE;
} }
...@@ -423,8 +422,7 @@ static BOOL add_to_task_list(WCHAR *name) ...@@ -423,8 +422,7 @@ static BOOL add_to_task_list(WCHAR *name)
void *realloc_list; void *realloc_list;
list_size *= 2; list_size *= 2;
realloc_list = HeapReAlloc(GetProcessHeap(), 0, task_list, realloc_list = realloc(task_list, list_size * sizeof(*task_list));
list_size * sizeof(*task_list));
if (!realloc_list) if (!realloc_list)
return FALSE; return FALSE;
...@@ -521,7 +519,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) ...@@ -521,7 +519,7 @@ int __cdecl wmain(int argc, WCHAR *argv[])
if (!process_arguments(argc, argv)) if (!process_arguments(argc, argv))
{ {
HeapFree(GetProcessHeap(), 0, task_list); free(task_list);
return 1; return 1;
} }
...@@ -530,6 +528,6 @@ int __cdecl wmain(int argc, WCHAR *argv[]) ...@@ -530,6 +528,6 @@ int __cdecl wmain(int argc, WCHAR *argv[])
else else
status_code = send_close_messages(); status_code = send_close_messages();
HeapFree(GetProcessHeap(), 0, task_list); free(task_list);
return status_code; return status_code;
} }
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