Commit 57927858 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

cmd: Use standard C functions for memory allocation.

parent 702b92ad
...@@ -68,7 +68,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA ...@@ -68,7 +68,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
prev_context = context; prev_context = context;
context = LocalAlloc (LMEM_FIXED, sizeof (BATCH_CONTEXT)); context = LocalAlloc (LMEM_FIXED, sizeof (BATCH_CONTEXT));
context -> h = h; context -> h = h;
context->batchfileW = heap_strdupW(file); context->batchfileW = xstrdupW(file);
context -> command = command; context -> command = command;
memset(context -> shift_count, 0x00, sizeof(context -> shift_count)); memset(context -> shift_count, 0x00, sizeof(context -> shift_count));
context -> prev_context = prev_context; context -> prev_context = prev_context;
...@@ -110,8 +110,8 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA ...@@ -110,8 +110,8 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
* to the caller's caller. * to the caller's caller.
*/ */
heap_free(context->batchfileW); free(context->batchfileW);
LocalFree (context); LocalFree(context);
if ((prev_context != NULL) && (!called)) { if ((prev_context != NULL) && (!called)) {
WINE_TRACE("Batch completed, but was not 'called' so skipping outer batch too\n"); WINE_TRACE("Batch completed, but was not 'called' so skipping outer batch too\n");
prev_context -> skip_rest = TRUE; prev_context -> skip_rest = TRUE;
...@@ -256,7 +256,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h) ...@@ -256,7 +256,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
const char *p; const char *p;
cp = GetOEMCP(); cp = GetOEMCP();
bufA = heap_xalloc(noChars); bufA = xalloc(noChars);
/* Save current file position */ /* Save current file position */
filepos.QuadPart = 0; filepos.QuadPart = 0;
...@@ -264,7 +264,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h) ...@@ -264,7 +264,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
status = ReadFile(h, bufA, noChars, &charsRead, NULL); status = ReadFile(h, bufA, noChars, &charsRead, NULL);
if (!status || charsRead == 0) { if (!status || charsRead == 0) {
heap_free(bufA); free(bufA);
return NULL; return NULL;
} }
...@@ -279,7 +279,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h) ...@@ -279,7 +279,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
SetFilePointerEx(h, filepos, NULL, FILE_BEGIN); SetFilePointerEx(h, filepos, NULL, FILE_BEGIN);
i = MultiByteToWideChar(cp, 0, bufA, p - bufA, buf, noChars); i = MultiByteToWideChar(cp, 0, bufA, p - bufA, buf, noChars);
heap_free(bufA); free(bufA);
} }
else { else {
if (!charsRead) return NULL; if (!charsRead) return NULL;
...@@ -454,11 +454,11 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute) ...@@ -454,11 +454,11 @@ void WCMD_HandleTildeModifiers(WCHAR **start, BOOL atExecute)
size = GetEnvironmentVariableW(env, NULL, 0); size = GetEnvironmentVariableW(env, NULL, 0);
if (size > 0) { if (size > 0) {
WCHAR *fullpath = heap_xalloc(size * sizeof(WCHAR)); WCHAR *fullpath = malloc(size * sizeof(WCHAR));
if (!fullpath || (GetEnvironmentVariableW(env, fullpath, size) == 0) || if (!fullpath || (GetEnvironmentVariableW(env, fullpath, size) == 0) ||
(SearchPathW(fullpath, outputparam, NULL, MAX_PATH, outputparam, NULL) == 0)) (SearchPathW(fullpath, outputparam, NULL, MAX_PATH, outputparam, NULL) == 0))
size = 0; size = 0;
heap_free(fullpath); free(fullpath);
} }
if (!size) { if (!size) {
......
...@@ -182,18 +182,18 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) { ...@@ -182,18 +182,18 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
ULONG domainLen = MAXSTRING; ULONG domainLen = MAXSTRING;
SID_NAME_USE nameuse; SID_NAME_USE nameuse;
secBuffer = heap_xalloc(sizeNeeded * sizeof(BYTE)); secBuffer = xalloc(sizeNeeded * sizeof(BYTE));
/* Get the owners security descriptor */ /* Get the owners security descriptor */
if(!GetFileSecurityW(filename, OWNER_SECURITY_INFORMATION, secBuffer, if(!GetFileSecurityW(filename, OWNER_SECURITY_INFORMATION, secBuffer,
sizeNeeded, &sizeNeeded)) { sizeNeeded, &sizeNeeded)) {
heap_free(secBuffer); free(secBuffer);
return; return;
} }
/* Get the SID from the SD */ /* Get the SID from the SD */
if(!GetSecurityDescriptorOwner(secBuffer, &pSID, &defaulted)) { if(!GetSecurityDescriptorOwner(secBuffer, &pSID, &defaulted)) {
heap_free(secBuffer); free(secBuffer);
return; return;
} }
...@@ -201,7 +201,7 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) { ...@@ -201,7 +201,7 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
if (LookupAccountSidW(NULL, pSID, name, &nameLen, domain, &domainLen, &nameuse)) { if (LookupAccountSidW(NULL, pSID, name, &nameLen, domain, &domainLen, &nameuse)) {
swprintf(owner, ownerlen, L"%s%c%s", domain, '\\', name); swprintf(owner, ownerlen, L"%s%c%s", domain, '\\', name);
} }
heap_free(secBuffer); free(secBuffer);
} }
return; return;
} }
...@@ -242,7 +242,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le ...@@ -242,7 +242,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
same directory. Note issuing a directory header with no contents same directory. Note issuing a directory header with no contents
mirrors what windows does */ mirrors what windows does */
parms = inputparms; parms = inputparms;
fd = heap_xalloc(sizeof(WIN32_FIND_DATAW)); fd = xalloc(sizeof(WIN32_FIND_DATAW));
while (parms && lstrcmpW(inputparms->dirName, parms->dirName) == 0) { while (parms && lstrcmpW(inputparms->dirName, parms->dirName) == 0) {
concurrentDirs++; concurrentDirs++;
...@@ -267,7 +267,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le ...@@ -267,7 +267,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (tmpLen > widest) widest = tmpLen; if (tmpLen > widest) widest = tmpLen;
} }
fd = HeapReAlloc(GetProcessHeap(),0,fd,(entry_count+1)*sizeof(WIN32_FIND_DATAW)); fd = realloc(fd, (entry_count + 1) * sizeof(WIN32_FIND_DATAW));
if (fd == NULL) { if (fd == NULL) {
FindClose (hff); FindClose (hff);
WINE_ERR("Out of memory\n"); WINE_ERR("Out of memory\n");
...@@ -431,7 +431,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le ...@@ -431,7 +431,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
} }
} }
} }
heap_free(fd); free(fd);
/* When recursing, look in all subdirectories for matches */ /* When recursing, look in all subdirectories for matches */
if (recurse) { if (recurse) {
...@@ -466,13 +466,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le ...@@ -466,13 +466,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string)); WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string));
/* Allocate memory, add to list */ /* Allocate memory, add to list */
thisDir = heap_xalloc(sizeof(DIRECTORY_STACK)); thisDir = xalloc(sizeof(DIRECTORY_STACK));
if (dirStack == NULL) dirStack = thisDir; if (dirStack == NULL) dirStack = thisDir;
if (lastEntry != NULL) lastEntry->next = thisDir; if (lastEntry != NULL) lastEntry->next = thisDir;
lastEntry = thisDir; lastEntry = thisDir;
thisDir->next = NULL; thisDir->next = NULL;
thisDir->dirName = heap_strdupW(string); thisDir->dirName = xstrdupW(string);
thisDir->fileName = heap_strdupW(parms->fileName); thisDir->fileName = xstrdupW(parms->fileName);
parms = parms->next; parms = parms->next;
} }
} }
...@@ -484,9 +484,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le ...@@ -484,9 +484,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
dirStack = WCMD_list_directory (thisDir, 1); dirStack = WCMD_list_directory (thisDir, 1);
while (thisDir != dirStack) { while (thisDir != dirStack) {
DIRECTORY_STACK *tempDir = thisDir->next; DIRECTORY_STACK *tempDir = thisDir->next;
heap_free(thisDir->dirName); free(thisDir->dirName);
heap_free(thisDir->fileName); free(thisDir->fileName);
heap_free(thisDir); free(thisDir);
thisDir = tempDir; thisDir = tempDir;
} }
} }
...@@ -786,7 +786,7 @@ void WCMD_directory (WCHAR *args) ...@@ -786,7 +786,7 @@ void WCMD_directory (WCHAR *args)
} }
WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path)); WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));
thisEntry = heap_xalloc(sizeof(DIRECTORY_STACK)); thisEntry = xalloc(sizeof(DIRECTORY_STACK));
if (fullParms == NULL) fullParms = thisEntry; if (fullParms == NULL) fullParms = thisEntry;
if (prevEntry != NULL) prevEntry->next = thisEntry; if (prevEntry != NULL) prevEntry->next = thisEntry;
prevEntry = thisEntry; prevEntry = thisEntry;
...@@ -798,11 +798,11 @@ void WCMD_directory (WCHAR *args) ...@@ -798,11 +798,11 @@ void WCMD_directory (WCHAR *args)
wine_dbgstr_w(drive), wine_dbgstr_w(dir), wine_dbgstr_w(drive), wine_dbgstr_w(dir),
wine_dbgstr_w(fname), wine_dbgstr_w(ext)); wine_dbgstr_w(fname), wine_dbgstr_w(ext));
thisEntry->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(drive)+lstrlenW(dir)+1)); thisEntry->dirName = xalloc(sizeof(WCHAR) * (wcslen(drive) + wcslen(dir) + 1));
lstrcpyW(thisEntry->dirName, drive); lstrcpyW(thisEntry->dirName, drive);
lstrcatW(thisEntry->dirName, dir); lstrcatW(thisEntry->dirName, dir);
thisEntry->fileName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(fname)+lstrlenW(ext)+1)); thisEntry->fileName = xalloc(sizeof(WCHAR) * (wcslen(fname) + wcslen(ext) + 1));
lstrcpyW(thisEntry->fileName, fname); lstrcpyW(thisEntry->fileName, fname);
lstrcatW(thisEntry->fileName, ext); lstrcatW(thisEntry->fileName, ext);
...@@ -812,10 +812,10 @@ void WCMD_directory (WCHAR *args) ...@@ -812,10 +812,10 @@ void WCMD_directory (WCHAR *args)
/* If just 'dir' entered, a '*' parameter is assumed */ /* If just 'dir' entered, a '*' parameter is assumed */
if (fullParms == NULL) { if (fullParms == NULL) {
WINE_TRACE("Inserting default '*'\n"); WINE_TRACE("Inserting default '*'\n");
fullParms = heap_xalloc(sizeof(DIRECTORY_STACK)); fullParms = xalloc(sizeof(DIRECTORY_STACK));
fullParms->next = NULL; fullParms->next = NULL;
fullParms->dirName = heap_strdupW(cwd); fullParms->dirName = xstrdupW(cwd);
fullParms->fileName = heap_strdupW(L"*"); fullParms->fileName = xstrdupW(L"*");
} }
lastDrive = '?'; lastDrive = '?';
...@@ -872,8 +872,8 @@ exit: ...@@ -872,8 +872,8 @@ exit:
while (fullParms != NULL) { while (fullParms != NULL) {
prevEntry = fullParms; prevEntry = fullParms;
fullParms = prevEntry->next; fullParms = prevEntry->next;
heap_free(prevEntry->dirName); free(prevEntry->dirName);
heap_free(prevEntry->fileName); free(prevEntry->fileName);
heap_free(prevEntry); free(prevEntry);
} }
} }
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <wchar.h> #include <wchar.h>
#include <wine/heap.h>
/* msdn specified max for Win XP */ /* msdn specified max for Win XP */
#define MAXSTRING 8192 #define MAXSTRING 8192
...@@ -125,9 +124,9 @@ void WCMD_free_commands(CMD_LIST *cmds); ...@@ -125,9 +124,9 @@ void WCMD_free_commands(CMD_LIST *cmds);
void WCMD_execute (const WCHAR *orig_command, const WCHAR *redirects, void WCMD_execute (const WCHAR *orig_command, const WCHAR *redirects,
CMD_LIST **cmdList, BOOL retrycall); CMD_LIST **cmdList, BOOL retrycall);
void *heap_xalloc(size_t); void *xalloc(size_t) __WINE_ALLOC_SIZE(1) __WINE_DEALLOC(free) __WINE_MALLOC;
static inline WCHAR *heap_strdupW(const WCHAR *str) static inline WCHAR *xstrdupW(const WCHAR *str)
{ {
WCHAR *ret = NULL; WCHAR *ret = NULL;
...@@ -135,7 +134,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str) ...@@ -135,7 +134,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
size_t size; size_t size;
size = (lstrlenW(str)+1)*sizeof(WCHAR); size = (lstrlenW(str)+1)*sizeof(WCHAR);
ret = heap_xalloc(size); ret = xalloc(size);
memcpy(ret, str, size); memcpy(ret, str, size);
} }
......
...@@ -67,7 +67,7 @@ static char *get_file_buffer(void) ...@@ -67,7 +67,7 @@ static char *get_file_buffer(void)
{ {
static char *output_bufA = NULL; static char *output_bufA = NULL;
if (!output_bufA) if (!output_bufA)
output_bufA = heap_xalloc(MAX_WRITECONSOLE_SIZE); output_bufA = xalloc(MAX_WRITECONSOLE_SIZE);
return output_bufA; return output_bufA;
} }
...@@ -423,11 +423,11 @@ static void WCMD_show_prompt (BOOL newLine) { ...@@ -423,11 +423,11 @@ static void WCMD_show_prompt (BOOL newLine) {
WCMD_output_asis (out_string); WCMD_output_asis (out_string);
} }
void *heap_xalloc(size_t size) void *xalloc(size_t size)
{ {
void *ret; void *ret;
ret = heap_alloc(size); ret = malloc(size);
if(!ret) { if(!ret) {
ERR("Out of memory\n"); ERR("Out of memory\n");
ExitProcess(1); ExitProcess(1);
...@@ -732,16 +732,16 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) ...@@ -732,16 +732,16 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
WCHAR *searchFor; WCHAR *searchFor;
if (equalspos == NULL) return start+1; if (equalspos == NULL) return start+1;
s = heap_strdupW(endOfVar + 1); s = xstrdupW(endOfVar + 1);
/* Null terminate both strings */ /* Null terminate both strings */
thisVar[lstrlenW(thisVar)-1] = 0x00; thisVar[lstrlenW(thisVar)-1] = 0x00;
*equalspos = 0x00; *equalspos = 0x00;
/* Since we need to be case insensitive, copy the 2 buffers */ /* Since we need to be case insensitive, copy the 2 buffers */
searchIn = heap_strdupW(thisVarContents); searchIn = xstrdupW(thisVarContents);
CharUpperBuffW(searchIn, lstrlenW(thisVarContents)); CharUpperBuffW(searchIn, lstrlenW(thisVarContents));
searchFor = heap_strdupW(colonpos+1); searchFor = xstrdupW(colonpos + 1);
CharUpperBuffW(searchFor, lstrlenW(colonpos+1)); CharUpperBuffW(searchFor, lstrlenW(colonpos+1));
/* Handle wildcard case */ /* Handle wildcard case */
...@@ -779,9 +779,9 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar) ...@@ -779,9 +779,9 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start, WCHAR startchar)
thisVarContents + (lastFound-searchIn)); thisVarContents + (lastFound-searchIn));
lstrcatW(outputposn, s); lstrcatW(outputposn, s);
} }
heap_free(s); free(s);
heap_free(searchIn); free(searchIn);
heap_free(searchFor); free(searchFor);
} }
return start; return start;
} }
...@@ -971,7 +971,7 @@ static void init_msvcrt_io_block(STARTUPINFOW* st) ...@@ -971,7 +971,7 @@ static void init_msvcrt_io_block(STARTUPINFOW* st)
* its new input & output handles) * its new input & output handles)
*/ */
sz = max(sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * 3, st_p.cbReserved2); sz = max(sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * 3, st_p.cbReserved2);
ptr = heap_xalloc(sz); ptr = xalloc(sz);
flags = (char*)(ptr + sizeof(unsigned)); flags = (char*)(ptr + sizeof(unsigned));
handles = (HANDLE*)(flags + num * sizeof(char)); handles = (HANDLE*)(flags + num * sizeof(char));
...@@ -1221,7 +1221,7 @@ void WCMD_run_program (WCHAR *command, BOOL called) ...@@ -1221,7 +1221,7 @@ void WCMD_run_program (WCHAR *command, BOOL called)
Note: Launching internal wine processes cannot specify a full path to exe */ Note: Launching internal wine processes cannot specify a full path to exe */
status = CreateProcessW(thisDir, status = CreateProcessW(thisDir,
command, NULL, NULL, TRUE, 0, NULL, NULL, &st, &pe); command, NULL, NULL, TRUE, 0, NULL, NULL, &st, &pe);
heap_free(st.lpReserved2); free(st.lpReserved2);
if ((opt_c || opt_k) && !opt_s && !status if ((opt_c || opt_k) && !opt_s && !status
&& GetLastError()==ERROR_FILE_NOT_FOUND && command[0]=='\"') { && GetLastError()==ERROR_FILE_NOT_FOUND && command[0]=='\"') {
/* strip first and last quote WCHARacters and try again */ /* strip first and last quote WCHARacters and try again */
...@@ -1301,12 +1301,12 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, ...@@ -1301,12 +1301,12 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
wine_dbgstr_w(command), cmdList); wine_dbgstr_w(command), cmdList);
/* Move copy of the command onto the heap so it can be expanded */ /* Move copy of the command onto the heap so it can be expanded */
new_cmd = heap_xalloc(MAXSTRING * sizeof(WCHAR)); new_cmd = xalloc(MAXSTRING * sizeof(WCHAR));
lstrcpyW(new_cmd, command); lstrcpyW(new_cmd, command);
cmd = new_cmd; cmd = new_cmd;
/* Move copy of the redirects onto the heap so it can be expanded */ /* Move copy of the redirects onto the heap so it can be expanded */
new_redir = heap_xalloc(MAXSTRING * sizeof(WCHAR)); new_redir = xalloc(MAXSTRING * sizeof(WCHAR));
redir = new_redir; redir = new_redir;
/* Strip leading whitespaces, and a '@' if supplied */ /* Strip leading whitespaces, and a '@' if supplied */
...@@ -1389,8 +1389,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, ...@@ -1389,8 +1389,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WINE_TRACE("Got directory %s as %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(cmd)); WINE_TRACE("Got directory %s as %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(cmd));
status = SetCurrentDirectoryW(cmd); status = SetCurrentDirectoryW(cmd);
if (!status) WCMD_print_error (); if (!status) WCMD_print_error ();
heap_free(cmd ); free(cmd);
heap_free(new_redir); free(new_redir);
return; return;
} }
...@@ -1412,8 +1412,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, ...@@ -1412,8 +1412,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL); FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error (); WCMD_print_error ();
heap_free(cmd); free(cmd);
heap_free(new_redir); free(new_redir);
return; return;
} }
SetStdHandle (STD_INPUT_HANDLE, h); SetStdHandle (STD_INPUT_HANDLE, h);
...@@ -1427,8 +1427,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, ...@@ -1427,8 +1427,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
&sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); &sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error (); WCMD_print_error ();
heap_free(cmd); free(cmd);
heap_free(new_redir); free(new_redir);
return; return;
} }
SetStdHandle (STD_INPUT_HANDLE, h); SetStdHandle (STD_INPUT_HANDLE, h);
...@@ -1472,8 +1472,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, ...@@ -1472,8 +1472,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
&sa, creationDisposition, FILE_ATTRIBUTE_NORMAL, NULL); &sa, creationDisposition, FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error (); WCMD_print_error ();
heap_free(cmd); free(cmd);
heap_free(new_redir); free(new_redir);
return; return;
} }
if (SetFilePointer (h, 0, NULL, FILE_END) == if (SetFilePointer (h, 0, NULL, FILE_END) ==
...@@ -1643,8 +1643,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects, ...@@ -1643,8 +1643,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
WCMD_run_program (whichcmd, FALSE); WCMD_run_program (whichcmd, FALSE);
echo_mode = prev_echo_mode; echo_mode = prev_echo_mode;
} }
heap_free(cmd); free(cmd);
heap_free(new_redir); free(new_redir);
/* Restore old handles */ /* Restore old handles */
for (i=0; i<3; i++) { for (i=0; i<3; i++) {
...@@ -1705,16 +1705,16 @@ static void WCMD_addCommand(WCHAR *command, int *commandLen, ...@@ -1705,16 +1705,16 @@ static void WCMD_addCommand(WCHAR *command, int *commandLen,
CMD_LIST *thisEntry = NULL; CMD_LIST *thisEntry = NULL;
/* Allocate storage for command */ /* Allocate storage for command */
thisEntry = heap_xalloc(sizeof(CMD_LIST)); thisEntry = xalloc(sizeof(CMD_LIST));
/* Copy in the command */ /* Copy in the command */
if (command) { if (command) {
thisEntry->command = heap_xalloc((*commandLen+1) * sizeof(WCHAR)); thisEntry->command = xalloc((*commandLen + 1) * sizeof(WCHAR));
memcpy(thisEntry->command, command, *commandLen * sizeof(WCHAR)); memcpy(thisEntry->command, command, *commandLen * sizeof(WCHAR));
thisEntry->command[*commandLen] = 0x00; thisEntry->command[*commandLen] = 0x00;
/* Copy in the redirects */ /* Copy in the redirects */
thisEntry->redirects = heap_xalloc((*redirLen+1) * sizeof(WCHAR)); thisEntry->redirects = xalloc((*redirLen + 1) * sizeof(WCHAR));
memcpy(thisEntry->redirects, redirs, *redirLen * sizeof(WCHAR)); memcpy(thisEntry->redirects, redirs, *redirLen * sizeof(WCHAR));
thisEntry->redirects[*redirLen] = 0x00; thisEntry->redirects[*redirLen] = 0x00;
thisEntry->pipeFile[0] = 0x00; thisEntry->pipeFile[0] = 0x00;
...@@ -1845,7 +1845,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE ...@@ -1845,7 +1845,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
/* Allocate working space for a command read from keyboard, file etc */ /* Allocate working space for a command read from keyboard, file etc */
if (!extraSpace) if (!extraSpace)
extraSpace = heap_xalloc((MAXSTRING+1) * sizeof(WCHAR)); extraSpace = xalloc((MAXSTRING + 1) * sizeof(WCHAR));
if (!extraSpace) if (!extraSpace)
{ {
WINE_ERR("Could not allocate memory for extraSpace\n"); WINE_ERR("Could not allocate memory for extraSpace\n");
...@@ -2399,9 +2399,9 @@ void WCMD_free_commands(CMD_LIST *cmds) { ...@@ -2399,9 +2399,9 @@ void WCMD_free_commands(CMD_LIST *cmds) {
while (cmds) { while (cmds) {
CMD_LIST *thisCmd = cmds; CMD_LIST *thisCmd = cmds;
cmds = cmds->nextcommand; cmds = cmds->nextcommand;
heap_free(thisCmd->command); free(thisCmd->command);
heap_free(thisCmd->redirects); free(thisCmd->redirects);
heap_free(thisCmd); free(thisCmd);
} }
} }
...@@ -2516,7 +2516,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) ...@@ -2516,7 +2516,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCHAR *q1 = NULL,*q2 = NULL,*p; WCHAR *q1 = NULL,*q2 = NULL,*p;
/* Take a copy */ /* Take a copy */
cmd = heap_strdupW(arg); cmd = xstrdupW(arg);
/* opt_s left unflagged if the command starts with and contains exactly /* opt_s left unflagged if the command starts with and contains exactly
* one quoted string (exactly two quote characters). The quoted string * one quoted string (exactly two quote characters). The quoted string
...@@ -2674,7 +2674,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) ...@@ -2674,7 +2674,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCMD_free_commands(toExecute); WCMD_free_commands(toExecute);
toExecute = NULL; toExecute = NULL;
heap_free(cmd); free(cmd);
return errorlevel; return errorlevel;
} }
...@@ -2754,7 +2754,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[]) ...@@ -2754,7 +2754,7 @@ int __cdecl wmain (int argc, WCHAR *argvW[])
WCMD_process_commands(toExecute, FALSE, FALSE); WCMD_process_commands(toExecute, FALSE, FALSE);
WCMD_free_commands(toExecute); WCMD_free_commands(toExecute);
toExecute = NULL; toExecute = NULL;
heap_free(cmd); free(cmd);
} }
/* /*
......
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