From 0c01b71a4e0eaefb9afee0fdc465b9b368c42a71 Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Mon, 15 Jun 2009 10:59:45 +0200 Subject: [PATCH] cmd: Replace malloc() with HeapAlloc(). --- programs/cmd/builtins.c | 2 +- programs/cmd/wcmdmain.c | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index bcdf840e7bc..0e99f52659b 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1033,7 +1033,7 @@ void WCMD_part_execute(CMD_LIST **cmdList, WCHAR *firstcmd, WCHAR *variable, if (conditionTRUE && firstcmd && *firstcmd) { WCHAR *command = WCMD_strdupW(firstcmd); WCMD_execute (firstcmd, (*cmdList)->redirects, variable, value, cmdList); - free (command); + HeapFree(GetProcessHeap(), 0, command); } diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 7d3e5266d62..d3aea6d6b5a 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -416,8 +416,7 @@ static void WCMD_show_prompt (void) { */ WCHAR *WCMD_strdupW(WCHAR *input) { int len=strlenW(input)+1; - /* Note: Use malloc not HeapAlloc to emulate strdup */ - WCHAR *result = malloc(len * sizeof(WCHAR)); + WCHAR *result = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); memcpy(result, input, len * sizeof(WCHAR)); return result; } @@ -749,9 +748,9 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR *forVar, WCHAR *forVal) { thisVarContents + (lastFound-searchIn)); strcatW(outputposn, s); } - free(s); - free(searchIn); - free(searchFor); + HeapFree(GetProcessHeap(), 0, s); + HeapFree(GetProcessHeap(), 0, searchIn); + HeapFree(GetProcessHeap(), 0, searchFor); return start; } return start+1;