mirror of
git://source.winehq.org/git/wine.git
synced 2024-07-20 17:24:14 +00:00
cmd: Use standard C functions for memory allocation.
This commit is contained in:
parent
702b92ad23
commit
5792785879
|
@ -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
|
||||||
* 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)
|
||||||
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)
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
|
|
||||||
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) {
|
||||||
|
|
|
@ -270,7 +270,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
have_console = GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &oldmode);
|
have_console = GetConsoleMode(GetStdHandle(STD_INPUT_HANDLE), &oldmode);
|
||||||
errorlevel = 0;
|
errorlevel = 0;
|
||||||
|
|
||||||
my_command = heap_strdupW(WCMD_skip_leading_spaces((WCHAR*) args));
|
my_command = xstrdupW(WCMD_skip_leading_spaces((WCHAR*)args));
|
||||||
|
|
||||||
ptr = WCMD_skip_leading_spaces(my_command);
|
ptr = WCMD_skip_leading_spaces(my_command);
|
||||||
while (*ptr == '/') {
|
while (*ptr == '/') {
|
||||||
|
@ -283,7 +283,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
|
|
||||||
if (!*ptr || iswspace(*ptr)) {
|
if (!*ptr || iswspace(*ptr)) {
|
||||||
WINE_FIXME("bad parameter %s for /C\n", wine_dbgstr_w(ptr));
|
WINE_FIXME("bad parameter %s for /C\n", wine_dbgstr_w(ptr));
|
||||||
heap_free(my_command);
|
free(my_command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,7 +320,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
|
|
||||||
if (!opt_default || (*ptr != ',')) {
|
if (!opt_default || (*ptr != ',')) {
|
||||||
WINE_FIXME("bad option %s for /T\n", opt_default ? wine_dbgstr_w(ptr) : "");
|
WINE_FIXME("bad option %s for /T\n", opt_default ? wine_dbgstr_w(ptr) : "");
|
||||||
heap_free(my_command);
|
free(my_command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ptr++;
|
ptr++;
|
||||||
|
@ -339,7 +339,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
|
|
||||||
default:
|
default:
|
||||||
WINE_FIXME("bad parameter: %s\n", wine_dbgstr_w(ptr));
|
WINE_FIXME("bad parameter: %s\n", wine_dbgstr_w(ptr));
|
||||||
heap_free(my_command);
|
free(my_command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
answer[1] = 0; /* terminate single character string */
|
answer[1] = 0; /* terminate single character string */
|
||||||
if (!WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), answer, 1, &count))
|
if (!WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), answer, 1, &count))
|
||||||
{
|
{
|
||||||
heap_free(my_command);
|
free(my_command);
|
||||||
errorlevel = 0;
|
errorlevel = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -403,7 +403,7 @@ void WCMD_choice (const WCHAR * args) {
|
||||||
|
|
||||||
errorlevel = (ptr - opt_c) + 1;
|
errorlevel = (ptr - opt_c) + 1;
|
||||||
WINE_TRACE("answer: %ld\n", errorlevel);
|
WINE_TRACE("answer: %ld\n", errorlevel);
|
||||||
heap_free(my_command);
|
free(my_command);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -706,7 +706,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We have found something to process - build a COPY_FILE block to store it */
|
/* We have found something to process - build a COPY_FILE block to store it */
|
||||||
thiscopy = heap_xalloc(sizeof(COPY_FILES));
|
thiscopy = xalloc(sizeof(COPY_FILES));
|
||||||
|
|
||||||
WINE_TRACE("Not a switch, but probably a filename/list %s\n", wine_dbgstr_w(thisparam));
|
WINE_TRACE("Not a switch, but probably a filename/list %s\n", wine_dbgstr_w(thisparam));
|
||||||
thiscopy->concatenate = concatnextfilename;
|
thiscopy->concatenate = concatnextfilename;
|
||||||
|
@ -717,7 +717,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
leave space to append \* to the end) , then copy in character by character. Strip off
|
leave space to append \* to the end) , then copy in character by character. Strip off
|
||||||
quotes if we find them. */
|
quotes if we find them. */
|
||||||
len = lstrlenW(thisparam) + (sizeof(WCHAR) * 5); /* 5 spare characters, null + \*.* */
|
len = lstrlenW(thisparam) + (sizeof(WCHAR) * 5); /* 5 spare characters, null + \*.* */
|
||||||
thiscopy->name = heap_xalloc(len*sizeof(WCHAR));
|
thiscopy->name = xalloc(len * sizeof(WCHAR));
|
||||||
memset(thiscopy->name, 0x00, len);
|
memset(thiscopy->name, 0x00, len);
|
||||||
|
|
||||||
pos1 = thisparam;
|
pos1 = thisparam;
|
||||||
|
@ -796,7 +796,7 @@ void WCMD_copy(WCHAR * args) {
|
||||||
lstrcpyW(destname, L".");
|
lstrcpyW(destname, L".");
|
||||||
lstrcatW(destname, L"\\");
|
lstrcatW(destname, L"\\");
|
||||||
|
|
||||||
destination = heap_xalloc(sizeof(COPY_FILES));
|
destination = xalloc(sizeof(COPY_FILES));
|
||||||
if (destination == NULL) goto exitreturn;
|
if (destination == NULL) goto exitreturn;
|
||||||
destination->concatenate = FALSE; /* Not used for destination */
|
destination->concatenate = FALSE; /* Not used for destination */
|
||||||
destination->binarycopy = binarymode;
|
destination->binarycopy = binarymode;
|
||||||
|
@ -856,8 +856,8 @@ void WCMD_copy(WCHAR * args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save away the destination name*/
|
/* Save away the destination name*/
|
||||||
heap_free(destination->name);
|
free(destination->name);
|
||||||
destination->name = heap_strdupW(destname);
|
destination->name = xstrdupW(destname);
|
||||||
WINE_TRACE("Resolved destination is '%s' (calc later %d)\n",
|
WINE_TRACE("Resolved destination is '%s' (calc later %d)\n",
|
||||||
wine_dbgstr_w(destname), appendfirstsource);
|
wine_dbgstr_w(destname), appendfirstsource);
|
||||||
|
|
||||||
|
@ -984,8 +984,8 @@ void WCMD_copy(WCHAR * args) {
|
||||||
|
|
||||||
/* If we needed to save away the first filename, do it */
|
/* If we needed to save away the first filename, do it */
|
||||||
if (appendfirstsource && overwrite) {
|
if (appendfirstsource && overwrite) {
|
||||||
heap_free(destination->name);
|
free(destination->name);
|
||||||
destination->name = heap_strdupW(outname);
|
destination->name = xstrdupW(outname);
|
||||||
WINE_TRACE("Final resolved destination name : '%s'\n", wine_dbgstr_w(outname));
|
WINE_TRACE("Final resolved destination name : '%s'\n", wine_dbgstr_w(outname));
|
||||||
appendfirstsource = FALSE;
|
appendfirstsource = FALSE;
|
||||||
destisdirectory = FALSE;
|
destisdirectory = FALSE;
|
||||||
|
@ -1059,14 +1059,14 @@ exitreturn:
|
||||||
prevcopy = thiscopy;
|
prevcopy = thiscopy;
|
||||||
/* Free up this block*/
|
/* Free up this block*/
|
||||||
thiscopy = thiscopy -> next;
|
thiscopy = thiscopy -> next;
|
||||||
heap_free(prevcopy->name);
|
free(prevcopy->name);
|
||||||
heap_free(prevcopy);
|
free(prevcopy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free up the destination memory */
|
/* Free up the destination memory */
|
||||||
if (destination) {
|
if (destination) {
|
||||||
heap_free(destination->name);
|
free(destination->name);
|
||||||
heap_free(destination);
|
free(destination);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -1371,12 +1371,12 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
|
||||||
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(subParm));
|
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(subParm));
|
||||||
|
|
||||||
/* Allocate memory, add to list */
|
/* Allocate memory, add to list */
|
||||||
nextDir = heap_xalloc(sizeof(DIRECTORY_STACK));
|
nextDir = xalloc(sizeof(DIRECTORY_STACK));
|
||||||
if (allDirs == NULL) allDirs = nextDir;
|
if (allDirs == NULL) allDirs = nextDir;
|
||||||
if (lastEntry != NULL) lastEntry->next = nextDir;
|
if (lastEntry != NULL) lastEntry->next = nextDir;
|
||||||
lastEntry = nextDir;
|
lastEntry = nextDir;
|
||||||
nextDir->next = NULL;
|
nextDir->next = NULL;
|
||||||
nextDir->dirName = heap_strdupW(subParm);
|
nextDir->dirName = xstrdupW(subParm);
|
||||||
}
|
}
|
||||||
} while (FindNextFileW(hff, &fd) != 0);
|
} while (FindNextFileW(hff, &fd) != 0);
|
||||||
FindClose (hff);
|
FindClose (hff);
|
||||||
|
@ -1388,8 +1388,8 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
|
||||||
tempDir = allDirs->next;
|
tempDir = allDirs->next;
|
||||||
found |= WCMD_delete_one (allDirs->dirName);
|
found |= WCMD_delete_one (allDirs->dirName);
|
||||||
|
|
||||||
heap_free(allDirs->dirName);
|
free(allDirs->dirName);
|
||||||
heap_free(allDirs);
|
free(allDirs);
|
||||||
allDirs = tempDir;
|
allDirs = tempDir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1457,7 +1457,7 @@ static WCHAR *WCMD_strtrim(const WCHAR *s)
|
||||||
const WCHAR *start = s;
|
const WCHAR *start = s;
|
||||||
WCHAR* result;
|
WCHAR* result;
|
||||||
|
|
||||||
result = heap_xalloc((len + 1) * sizeof(WCHAR));
|
result = xalloc((len + 1) * sizeof(WCHAR));
|
||||||
|
|
||||||
while (iswspace(*start)) start++;
|
while (iswspace(*start)) start++;
|
||||||
if (*start) {
|
if (*start) {
|
||||||
|
@ -1497,7 +1497,7 @@ void WCMD_echo (const WCHAR *args)
|
||||||
&& origcommand[0]!=';' && origcommand[0]!='/') {
|
&& origcommand[0]!=';' && origcommand[0]!='/') {
|
||||||
if (echo_mode) WCMD_output(WCMD_LoadMessage(WCMD_ECHOPROMPT), L"ON");
|
if (echo_mode) WCMD_output(WCMD_LoadMessage(WCMD_ECHOPROMPT), L"ON");
|
||||||
else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), L"OFF");
|
else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), L"OFF");
|
||||||
heap_free(trimmed);
|
free(trimmed);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1509,7 +1509,7 @@ void WCMD_echo (const WCHAR *args)
|
||||||
WCMD_output_asis (args);
|
WCMD_output_asis (args);
|
||||||
WCMD_output_asis(L"\r\n");
|
WCMD_output_asis(L"\r\n");
|
||||||
}
|
}
|
||||||
heap_free(trimmed);
|
free(trimmed);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
@ -1533,9 +1533,9 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
|
||||||
|
|
||||||
/* Process the first command, if there is one */
|
/* Process the first command, if there is one */
|
||||||
if (executecmds && firstcmd && *firstcmd) {
|
if (executecmds && firstcmd && *firstcmd) {
|
||||||
WCHAR *command = heap_strdupW(firstcmd);
|
WCHAR *command = xstrdupW(firstcmd);
|
||||||
WCMD_execute (firstcmd, (*cmdList)->redirects, cmdList, FALSE);
|
WCMD_execute (firstcmd, (*cmdList)->redirects, cmdList, FALSE);
|
||||||
heap_free(command);
|
free(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1775,12 +1775,12 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
|
||||||
debugstr_w(dirsToWalk->dirName), debugstr_w(fd.cFileName));
|
debugstr_w(dirsToWalk->dirName), debugstr_w(fd.cFileName));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
toWalk = heap_xalloc(sizeof(DIRECTORY_STACK));
|
toWalk = xalloc(sizeof(DIRECTORY_STACK));
|
||||||
WINE_TRACE("(%p->%p)\n", remainingDirs, remainingDirs->next);
|
WINE_TRACE("(%p->%p)\n", remainingDirs, remainingDirs->next);
|
||||||
toWalk->next = remainingDirs->next;
|
toWalk->next = remainingDirs->next;
|
||||||
remainingDirs->next = toWalk;
|
remainingDirs->next = toWalk;
|
||||||
remainingDirs = toWalk;
|
remainingDirs = toWalk;
|
||||||
toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (lstrlenW(dirsToWalk->dirName) + 2 + lstrlenW(fd.cFileName)));
|
toWalk->dirName = xalloc(sizeof(WCHAR) * (wcslen(dirsToWalk->dirName) + 2 + wcslen(fd.cFileName)));
|
||||||
lstrcpyW(toWalk->dirName, dirsToWalk->dirName);
|
lstrcpyW(toWalk->dirName, dirsToWalk->dirName);
|
||||||
lstrcatW(toWalk->dirName, L"\\");
|
lstrcatW(toWalk->dirName, L"\\");
|
||||||
lstrcatW(toWalk->dirName, fd.cFileName);
|
lstrcatW(toWalk->dirName, fd.cFileName);
|
||||||
|
@ -2003,7 +2003,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
|
||||||
WINE_TRACE("Parsed token %d(%d) as parameter %s\n", nexttoken,
|
WINE_TRACE("Parsed token %d(%d) as parameter %s\n", nexttoken,
|
||||||
varidx + varoffset, wine_dbgstr_w(parm));
|
varidx + varoffset, wine_dbgstr_w(parm));
|
||||||
if (varidx >=0) {
|
if (varidx >=0) {
|
||||||
if (parm) forloopcontext.variable[varidx + varoffset] = heap_strdupW(parm);
|
if (parm) forloopcontext.variable[varidx + varoffset] = xstrdupW(parm);
|
||||||
varoffset++;
|
varoffset++;
|
||||||
if (((varidx%26)+varoffset) >= 26) break;
|
if (((varidx%26)+varoffset) >= 26) break;
|
||||||
}
|
}
|
||||||
|
@ -2021,7 +2021,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
|
||||||
WCMD_parameter_with_delims(buffer, (nexttoken-1), &parm, FALSE, FALSE, forf_delims);
|
WCMD_parameter_with_delims(buffer, (nexttoken-1), &parm, FALSE, FALSE, forf_delims);
|
||||||
WINE_TRACE("Parsed allremaining tokens (%d) as parameter %s\n",
|
WINE_TRACE("Parsed allremaining tokens (%d) as parameter %s\n",
|
||||||
varidx + varoffset, wine_dbgstr_w(parm));
|
varidx + varoffset, wine_dbgstr_w(parm));
|
||||||
if (parm) forloopcontext.variable[varidx + varoffset] = heap_strdupW(parm);
|
if (parm) forloopcontext.variable[varidx + varoffset] = xstrdupW(parm);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Execute the body of the foor loop with these values */
|
/* Execute the body of the foor loop with these values */
|
||||||
|
@ -2038,7 +2038,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
|
||||||
for (i=varidx; i<MAX_FOR_VARIABLES; i++) {
|
for (i=varidx; i<MAX_FOR_VARIABLES; i++) {
|
||||||
if ((forloopcontext.variable[i] != oldcontext.variable[i]) &&
|
if ((forloopcontext.variable[i] != oldcontext.variable[i]) &&
|
||||||
(forloopcontext.variable[i] != emptyW)) {
|
(forloopcontext.variable[i] != emptyW)) {
|
||||||
heap_free(forloopcontext.variable[i]);
|
free(forloopcontext.variable[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2103,7 +2103,7 @@ static FILE* WCMD_forf_getinput(BOOL usebackq, WCHAR *itemstr, BOOL iscmd) {
|
||||||
WINE_TRACE("Reading input to parse from '%s'\n", wine_dbgstr_w(itemstr));
|
WINE_TRACE("Reading input to parse from '%s'\n", wine_dbgstr_w(itemstr));
|
||||||
ret = _wfopen(itemstr, L"rt,ccs=unicode");
|
ret = _wfopen(itemstr, L"rt,ccs=unicode");
|
||||||
}
|
}
|
||||||
heap_free(trimmed);
|
free(trimmed);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2209,9 +2209,9 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
/* Set up the list of directories to recurse if we are going to */
|
/* Set up the list of directories to recurse if we are going to */
|
||||||
} else if (doRecurse) {
|
} else if (doRecurse) {
|
||||||
/* Allocate memory, add to list */
|
/* Allocate memory, add to list */
|
||||||
dirsToWalk = heap_xalloc(sizeof(DIRECTORY_STACK));
|
dirsToWalk = xalloc(sizeof(DIRECTORY_STACK));
|
||||||
dirsToWalk->next = NULL;
|
dirsToWalk->next = NULL;
|
||||||
dirsToWalk->dirName = heap_strdupW(optionsRoot);
|
dirsToWalk->dirName = xstrdupW(optionsRoot);
|
||||||
WINE_TRACE("Starting with root directory %s\n", wine_dbgstr_w(dirsToWalk->dirName));
|
WINE_TRACE("Starting with root directory %s\n", wine_dbgstr_w(dirsToWalk->dirName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2500,8 +2500,8 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
||||||
/* If we are walking directories, move on to any which remain */
|
/* If we are walking directories, move on to any which remain */
|
||||||
if (dirsToWalk != NULL) {
|
if (dirsToWalk != NULL) {
|
||||||
DIRECTORY_STACK *nextDir = dirsToWalk->next;
|
DIRECTORY_STACK *nextDir = dirsToWalk->next;
|
||||||
heap_free(dirsToWalk->dirName);
|
free(dirsToWalk->dirName);
|
||||||
heap_free(dirsToWalk);
|
free(dirsToWalk);
|
||||||
dirsToWalk = nextDir;
|
dirsToWalk = nextDir;
|
||||||
if (dirsToWalk) WINE_TRACE("Moving to next directory to iterate: %s\n",
|
if (dirsToWalk) WINE_TRACE("Moving to next directory to iterate: %s\n",
|
||||||
wine_dbgstr_w(dirsToWalk->dirName));
|
wine_dbgstr_w(dirsToWalk->dirName));
|
||||||
|
@ -3666,7 +3666,7 @@ static int WCMD_getprecedence(const WCHAR in)
|
||||||
* stack
|
* stack
|
||||||
*/
|
*/
|
||||||
static void WCMD_pushnumber(WCHAR *var, int num, VARSTACK **varstack) {
|
static void WCMD_pushnumber(WCHAR *var, int num, VARSTACK **varstack) {
|
||||||
VARSTACK *thisstack = heap_xalloc(sizeof(VARSTACK));
|
VARSTACK *thisstack = xalloc(sizeof(VARSTACK));
|
||||||
thisstack->isnum = (var == NULL);
|
thisstack->isnum = (var == NULL);
|
||||||
if (var) {
|
if (var) {
|
||||||
thisstack->variable = var;
|
thisstack->variable = var;
|
||||||
|
@ -3716,9 +3716,9 @@ static int WCMD_popnumber(VARSTACK **varstack) {
|
||||||
if (varstack) {
|
if (varstack) {
|
||||||
thisvar = *varstack;
|
thisvar = *varstack;
|
||||||
result = WCMD_peeknumber(varstack);
|
result = WCMD_peeknumber(varstack);
|
||||||
if (!thisvar->isnum) heap_free(thisvar->variable);
|
if (!thisvar->isnum) free(thisvar->variable);
|
||||||
*varstack = thisvar->next;
|
*varstack = thisvar->next;
|
||||||
heap_free(thisvar);
|
free(thisvar);
|
||||||
}
|
}
|
||||||
WINE_TRACE("Popped number %d\n", result);
|
WINE_TRACE("Popped number %d\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -3729,7 +3729,7 @@ static int WCMD_popnumber(VARSTACK **varstack) {
|
||||||
* Push an operator onto the supplied stack
|
* Push an operator onto the supplied stack
|
||||||
*/
|
*/
|
||||||
static void WCMD_pushoperator(WCHAR op, int precedence, OPSTACK **opstack) {
|
static void WCMD_pushoperator(WCHAR op, int precedence, OPSTACK **opstack) {
|
||||||
OPSTACK *thisstack = heap_xalloc(sizeof(OPSTACK));
|
OPSTACK *thisstack = xalloc(sizeof(OPSTACK));
|
||||||
thisstack->precedence = precedence;
|
thisstack->precedence = precedence;
|
||||||
thisstack->op = op;
|
thisstack->op = op;
|
||||||
thisstack->next = *opstack;
|
thisstack->next = *opstack;
|
||||||
|
@ -3750,7 +3750,7 @@ static WCHAR WCMD_popoperator(OPSTACK **opstack) {
|
||||||
thisop = *opstack;
|
thisop = *opstack;
|
||||||
result = thisop->op;
|
result = thisop->op;
|
||||||
*opstack = thisop->next;
|
*opstack = thisop->next;
|
||||||
heap_free(thisop);
|
free(thisop);
|
||||||
}
|
}
|
||||||
WINE_TRACE("Popped operator %c\n", result);
|
WINE_TRACE("Popped operator %c\n", result);
|
||||||
return result;
|
return result;
|
||||||
|
@ -3954,7 +3954,7 @@ static int WCMD_handleExpression(WCHAR **expr, int *ret, int depth)
|
||||||
|
|
||||||
/* For a variable - just push it onto the stack */
|
/* For a variable - just push it onto the stack */
|
||||||
parm = WCMD_parameter_with_delims(pos, 0, &parmstart, FALSE, FALSE, mathDelims);
|
parm = WCMD_parameter_with_delims(pos, 0, &parmstart, FALSE, FALSE, mathDelims);
|
||||||
dupparm = heap_strdupW(parm);
|
dupparm = xstrdupW(parm);
|
||||||
WCMD_pushnumber(dupparm, 0, &varstackhead);
|
WCMD_pushnumber(dupparm, 0, &varstackhead);
|
||||||
pos = parmstart + lstrlenW(dupparm);
|
pos = parmstart + lstrlenW(dupparm);
|
||||||
}
|
}
|
||||||
|
@ -4064,7 +4064,7 @@ static int WCMD_handleExpression(WCHAR **expr, int *ret, int depth)
|
||||||
}
|
}
|
||||||
prevresult = WCMD_popnumber(&varstackhead);
|
prevresult = WCMD_popnumber(&varstackhead);
|
||||||
WINE_TRACE("Expression resolved to %d\n", prevresult);
|
WINE_TRACE("Expression resolved to %d\n", prevresult);
|
||||||
heap_free(varstackhead);
|
free(varstackhead);
|
||||||
varstackhead = NULL;
|
varstackhead = NULL;
|
||||||
pos++;
|
pos++;
|
||||||
break;
|
break;
|
||||||
|
@ -4194,7 +4194,7 @@ void WCMD_setshow_env (WCHAR *s) {
|
||||||
WCHAR *src,*dst;
|
WCHAR *src,*dst;
|
||||||
|
|
||||||
/* Remove all quotes before doing any calculations */
|
/* Remove all quotes before doing any calculations */
|
||||||
thisexpr = heap_xalloc((lstrlenW(s+2)+1) * sizeof(WCHAR));
|
thisexpr = xalloc((wcslen(s + 2) + 1) * sizeof(WCHAR));
|
||||||
src = s+2;
|
src = s+2;
|
||||||
dst = thisexpr;
|
dst = thisexpr;
|
||||||
while (*src) {
|
while (*src) {
|
||||||
|
@ -4206,7 +4206,7 @@ void WCMD_setshow_env (WCHAR *s) {
|
||||||
/* Now calculate the results of the expression */
|
/* Now calculate the results of the expression */
|
||||||
src = thisexpr;
|
src = thisexpr;
|
||||||
rc = WCMD_handleExpression(&src, &result, 0);
|
rc = WCMD_handleExpression(&src, &result, 0);
|
||||||
heap_free(thisexpr);
|
free(thisexpr);
|
||||||
|
|
||||||
/* If parsing failed, issue the error message */
|
/* If parsing failed, issue the error message */
|
||||||
if (rc > 0) {
|
if (rc > 0) {
|
||||||
|
@ -4385,7 +4385,7 @@ void WCMD_start(WCHAR *args)
|
||||||
|
|
||||||
GetSystemDirectoryW( file, MAX_PATH );
|
GetSystemDirectoryW( file, MAX_PATH );
|
||||||
lstrcatW(file, L"\\start.exe");
|
lstrcatW(file, L"\\start.exe");
|
||||||
cmdline = heap_xalloc( (lstrlenW(file) + lstrlenW(args) + 8) * sizeof(WCHAR) );
|
cmdline = xalloc( (wcslen(file) + wcslen(args) + 8) * sizeof(WCHAR) );
|
||||||
lstrcpyW( cmdline, file );
|
lstrcpyW( cmdline, file );
|
||||||
lstrcatW(cmdline, L" ");
|
lstrcatW(cmdline, L" ");
|
||||||
cmdline_params = cmdline + lstrlenW(cmdline);
|
cmdline_params = cmdline + lstrlenW(cmdline);
|
||||||
|
@ -4488,7 +4488,7 @@ void WCMD_start(WCHAR *args)
|
||||||
WCMD_print_error ();
|
WCMD_print_error ();
|
||||||
errorlevel = 9009;
|
errorlevel = 9009;
|
||||||
}
|
}
|
||||||
heap_free(cmdline);
|
free(cmdline);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
|
@ -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) {
|
||||||
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
|
||||||
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
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
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
|
||||||
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
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
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)
|
||||||
/* 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:
|
||||||
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 @@
|
||||||
#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);
|
||||||
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)
|
||||||
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)
|
||||||
{
|
{
|
||||||
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) {
|
||||||
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)
|
||||||
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)
|
||||||
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)
|
||||||
* 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)
|
||||||
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,
|
||||||
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,
|
||||||
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,
|
||||||
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,
|
||||||
&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,
|
||||||
&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,
|
||||||
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,
|
||||||
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
|
||||||
|
|
||||||
/* 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) {
|
||||||
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[])
|
||||||
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[])
|
||||||
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[])
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue