mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 10:41:12 +00:00
cmd: Added HeapFree wrapper.
This commit is contained in:
parent
62e77128c5
commit
08c17ada57
5 changed files with 55 additions and 50 deletions
|
@ -110,7 +110,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, BOOL called, WCHAR *startLabel, HA
|
|||
* to the caller's caller.
|
||||
*/
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, context->batchfileW);
|
||||
heap_free(context->batchfileW);
|
||||
LocalFree (context);
|
||||
if ((prev_context != NULL) && (!called)) {
|
||||
WINE_TRACE("Batch completed, but was not 'called' so skipping outer batch too\n");
|
||||
|
@ -265,7 +265,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
|
|||
|
||||
status = ReadFile(h, bufA, noChars, &charsRead, NULL);
|
||||
if (!status || charsRead == 0) {
|
||||
HeapFree(GetProcessHeap(), 0, bufA);
|
||||
heap_free(bufA);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
|
|||
SetFilePointerEx(h, filepos, NULL, FILE_BEGIN);
|
||||
|
||||
i = MultiByteToWideChar(cp, 0, bufA, p - bufA, buf, noChars);
|
||||
HeapFree(GetProcessHeap(), 0, bufA);
|
||||
heap_free(bufA);
|
||||
}
|
||||
else {
|
||||
status = WCMD_ReadFile(h, buf, noChars, &charsRead);
|
||||
|
|
|
@ -243,7 +243,7 @@ void WCMD_choice (const WCHAR * args) {
|
|||
|
||||
if (!*ptr || isspaceW(*ptr)) {
|
||||
WINE_FIXME("bad parameter %s for /C\n", wine_dbgstr_w(ptr));
|
||||
HeapFree(GetProcessHeap(), 0, my_command);
|
||||
heap_free(my_command);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -280,7 +280,7 @@ void WCMD_choice (const WCHAR * args) {
|
|||
|
||||
if (!opt_default || (*ptr != ',')) {
|
||||
WINE_FIXME("bad option %s for /T\n", opt_default ? wine_dbgstr_w(ptr) : "");
|
||||
HeapFree(GetProcessHeap(), 0, my_command);
|
||||
heap_free(my_command);
|
||||
return;
|
||||
}
|
||||
ptr++;
|
||||
|
@ -299,7 +299,7 @@ void WCMD_choice (const WCHAR * args) {
|
|||
|
||||
default:
|
||||
WINE_FIXME("bad parameter: %s\n", wine_dbgstr_w(ptr));
|
||||
HeapFree(GetProcessHeap(), 0, my_command);
|
||||
heap_free(my_command);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -357,7 +357,7 @@ void WCMD_choice (const WCHAR * args) {
|
|||
|
||||
errorlevel = (ptr - opt_c) + 1;
|
||||
WINE_TRACE("answer: %d\n", errorlevel);
|
||||
HeapFree(GetProcessHeap(), 0, my_command);
|
||||
heap_free(my_command);
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -780,7 +780,7 @@ void WCMD_copy(WCHAR * args) {
|
|||
}
|
||||
|
||||
/* Save away the destination name*/
|
||||
HeapFree(GetProcessHeap(), 0, destination->name);
|
||||
heap_free(destination->name);
|
||||
destination->name = heap_strdupW(destname);
|
||||
WINE_TRACE("Resolved destination is '%s' (calc later %d)\n",
|
||||
wine_dbgstr_w(destname), appendfirstsource);
|
||||
|
@ -881,7 +881,7 @@ void WCMD_copy(WCHAR * args) {
|
|||
|
||||
/* If we needed tyo save away the first filename, do it */
|
||||
if (appendfirstsource && overwrite) {
|
||||
HeapFree(GetProcessHeap(), 0, destination->name);
|
||||
heap_free(destination->name);
|
||||
destination->name = heap_strdupW(outname);
|
||||
WINE_TRACE("Final resolved destination name : '%s'\n", wine_dbgstr_w(outname));
|
||||
appendfirstsource = FALSE;
|
||||
|
@ -951,14 +951,14 @@ exitreturn:
|
|||
prevcopy = thiscopy;
|
||||
/* Free up this block*/
|
||||
thiscopy = thiscopy -> next;
|
||||
HeapFree(GetProcessHeap(), 0, prevcopy->name);
|
||||
HeapFree(GetProcessHeap(), 0, prevcopy);
|
||||
heap_free(prevcopy->name);
|
||||
heap_free(prevcopy);
|
||||
}
|
||||
|
||||
/* Free up the destination memory */
|
||||
if (destination) {
|
||||
HeapFree(GetProcessHeap(), 0, destination->name);
|
||||
HeapFree(GetProcessHeap(), 0, destination);
|
||||
heap_free(destination->name);
|
||||
heap_free(destination);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -1285,8 +1285,8 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
|
|||
tempDir = allDirs->next;
|
||||
found |= WCMD_delete_one (allDirs->dirName);
|
||||
|
||||
HeapFree(GetProcessHeap(),0,allDirs->dirName);
|
||||
HeapFree(GetProcessHeap(),0,allDirs);
|
||||
heap_free(allDirs->dirName);
|
||||
heap_free(allDirs);
|
||||
allDirs = tempDir;
|
||||
}
|
||||
}
|
||||
|
@ -1396,7 +1396,7 @@ void WCMD_echo (const WCHAR *args)
|
|||
&& origcommand[0]!=';') {
|
||||
if (echo_mode) WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), onW);
|
||||
else WCMD_output (WCMD_LoadMessage(WCMD_ECHOPROMPT), offW);
|
||||
HeapFree(GetProcessHeap(), 0, trimmed);
|
||||
heap_free(trimmed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1408,7 +1408,7 @@ void WCMD_echo (const WCHAR *args)
|
|||
WCMD_output_asis (args);
|
||||
WCMD_output_asis (newlineW);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, trimmed);
|
||||
heap_free(trimmed);
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -1435,7 +1435,7 @@ static void WCMD_part_execute(CMD_LIST **cmdList, const WCHAR *firstcmd,
|
|||
if (executecmds && firstcmd && *firstcmd) {
|
||||
WCHAR *command = heap_strdupW(firstcmd);
|
||||
WCMD_execute (firstcmd, (*cmdList)->redirects, cmdList, FALSE);
|
||||
HeapFree(GetProcessHeap(), 0, command);
|
||||
heap_free(command);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1728,7 +1728,7 @@ static void WCMD_parse_line(CMD_LIST *cmdStart,
|
|||
*cmdEnd = thisCmdStart;
|
||||
}
|
||||
|
||||
if (varidx >=0) HeapFree(GetProcessHeap(), 0, forloopcontext.variable[varidx]);
|
||||
if (varidx >=0) heap_free(forloopcontext.variable[varidx]);
|
||||
|
||||
/* Restore the original for variable contextx */
|
||||
forloopcontext = oldcontext;
|
||||
|
@ -2171,8 +2171,8 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
|||
/* If we are walking directories, move on to any which remain */
|
||||
if (dirsToWalk != NULL) {
|
||||
DIRECTORY_STACK *nextDir = dirsToWalk->next;
|
||||
HeapFree(GetProcessHeap(), 0, dirsToWalk->dirName);
|
||||
HeapFree(GetProcessHeap(), 0, dirsToWalk);
|
||||
heap_free(dirsToWalk->dirName);
|
||||
heap_free(dirsToWalk);
|
||||
dirsToWalk = nextDir;
|
||||
if (dirsToWalk) WINE_TRACE("Moving to next directorty to iterate: %s\n",
|
||||
wine_dbgstr_w(dirsToWalk->dirName));
|
||||
|
@ -3446,7 +3446,7 @@ void WCMD_start(const WCHAR *args)
|
|||
WCMD_print_error ();
|
||||
errorlevel = 9009;
|
||||
}
|
||||
HeapFree( GetProcessHeap(), 0, cmdline );
|
||||
heap_free(cmdline);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
|
|
@ -208,13 +208,13 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
|
|||
/* Get the owners security descriptor */
|
||||
if(!GetFileSecurityW(filename, OWNER_SECURITY_INFORMATION, secBuffer,
|
||||
sizeNeeded, &sizeNeeded)) {
|
||||
HeapFree(GetProcessHeap(),0,secBuffer);
|
||||
heap_free(secBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Get the SID from the SD */
|
||||
if(!GetSecurityDescriptorOwner(secBuffer, &pSID, &defaulted)) {
|
||||
HeapFree(GetProcessHeap(),0,secBuffer);
|
||||
heap_free(secBuffer);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
|
|||
static const WCHAR fmt[] = {'%','s','%','c','%','s','\0'};
|
||||
snprintfW(owner, ownerlen, fmt, domain, '\\', name);
|
||||
}
|
||||
HeapFree(GetProcessHeap(),0,secBuffer);
|
||||
heap_free(secBuffer);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -477,7 +477,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
|||
}
|
||||
}
|
||||
}
|
||||
HeapFree(GetProcessHeap(),0,fd);
|
||||
heap_free(fd);
|
||||
|
||||
/* When recursing, look in all subdirectories for matches */
|
||||
if (recurse) {
|
||||
|
@ -530,9 +530,9 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
|||
dirStack = WCMD_list_directory (thisDir, 1);
|
||||
while (thisDir != dirStack) {
|
||||
DIRECTORY_STACK *tempDir = thisDir->next;
|
||||
HeapFree(GetProcessHeap(),0,thisDir->dirName);
|
||||
HeapFree(GetProcessHeap(),0,thisDir->fileName);
|
||||
HeapFree(GetProcessHeap(),0,thisDir);
|
||||
heap_free(thisDir->dirName);
|
||||
heap_free(thisDir->fileName);
|
||||
heap_free(thisDir);
|
||||
thisDir = tempDir;
|
||||
}
|
||||
}
|
||||
|
@ -935,8 +935,8 @@ exit:
|
|||
while (fullParms != NULL) {
|
||||
prevEntry = fullParms;
|
||||
fullParms = prevEntry->next;
|
||||
HeapFree(GetProcessHeap(),0,prevEntry->dirName);
|
||||
HeapFree(GetProcessHeap(),0,prevEntry->fileName);
|
||||
HeapFree(GetProcessHeap(),0,prevEntry);
|
||||
heap_free(prevEntry->dirName);
|
||||
heap_free(prevEntry->fileName);
|
||||
heap_free(prevEntry);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -128,6 +128,11 @@ void WCMD_execute (const WCHAR *orig_command, const WCHAR *redirects,
|
|||
|
||||
void *heap_alloc(size_t);
|
||||
|
||||
static inline BOOL heap_free(void *mem)
|
||||
{
|
||||
return HeapFree(GetProcessHeap(), 0, mem);
|
||||
}
|
||||
|
||||
static inline WCHAR *heap_strdupW(const WCHAR *str)
|
||||
{
|
||||
WCHAR *ret = NULL;
|
||||
|
|
|
@ -777,9 +777,9 @@ static WCHAR *WCMD_expand_envvar(WCHAR *start)
|
|||
thisVarContents + (lastFound-searchIn));
|
||||
strcatW(outputposn, s);
|
||||
}
|
||||
HeapFree(GetProcessHeap(), 0, s);
|
||||
HeapFree(GetProcessHeap(), 0, searchIn);
|
||||
HeapFree(GetProcessHeap(), 0, searchFor);
|
||||
heap_free(s);
|
||||
heap_free(searchIn);
|
||||
heap_free(searchFor);
|
||||
}
|
||||
return start;
|
||||
}
|
||||
|
@ -1330,8 +1330,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));
|
||||
status = SetCurrentDirectoryW(cmd);
|
||||
if (!status) WCMD_print_error ();
|
||||
HeapFree( GetProcessHeap(), 0, cmd );
|
||||
HeapFree( GetProcessHeap(), 0, new_redir );
|
||||
heap_free(cmd );
|
||||
heap_free(new_redir);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1351,8 +1351,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
|||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
WCMD_print_error ();
|
||||
HeapFree( GetProcessHeap(), 0, cmd );
|
||||
HeapFree( GetProcessHeap(), 0, new_redir );
|
||||
heap_free(cmd);
|
||||
heap_free(new_redir);
|
||||
return;
|
||||
}
|
||||
SetStdHandle (STD_INPUT_HANDLE, h);
|
||||
|
@ -1366,8 +1366,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
|||
&sa, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
WCMD_print_error ();
|
||||
HeapFree( GetProcessHeap(), 0, cmd );
|
||||
HeapFree( GetProcessHeap(), 0, new_redir );
|
||||
heap_free(cmd);
|
||||
heap_free(new_redir);
|
||||
return;
|
||||
}
|
||||
SetStdHandle (STD_INPUT_HANDLE, h);
|
||||
|
@ -1412,8 +1412,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
|||
FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (h == INVALID_HANDLE_VALUE) {
|
||||
WCMD_print_error ();
|
||||
HeapFree( GetProcessHeap(), 0, cmd );
|
||||
HeapFree( GetProcessHeap(), 0, new_redir );
|
||||
heap_free(cmd);
|
||||
heap_free(new_redir);
|
||||
return;
|
||||
}
|
||||
if (SetFilePointer (h, 0, NULL, FILE_END) ==
|
||||
|
@ -1599,8 +1599,8 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
|||
WCMD_run_program (whichcmd, FALSE);
|
||||
echo_mode = prev_echo_mode;
|
||||
}
|
||||
HeapFree( GetProcessHeap(), 0, cmd );
|
||||
HeapFree( GetProcessHeap(), 0, new_redir );
|
||||
heap_free(cmd);
|
||||
heap_free(new_redir);
|
||||
|
||||
/* Restore old handles */
|
||||
for (i=0; i<3; i++) {
|
||||
|
@ -2293,9 +2293,9 @@ void WCMD_free_commands(CMD_LIST *cmds) {
|
|||
while (cmds) {
|
||||
CMD_LIST *thisCmd = cmds;
|
||||
cmds = cmds->nextcommand;
|
||||
HeapFree(GetProcessHeap(), 0, thisCmd->command);
|
||||
HeapFree(GetProcessHeap(), 0, thisCmd->redirects);
|
||||
HeapFree(GetProcessHeap(), 0, thisCmd);
|
||||
heap_free(thisCmd->command);
|
||||
heap_free(thisCmd->redirects);
|
||||
heap_free(thisCmd);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2561,7 +2561,7 @@ int wmain (int argc, WCHAR *argvW[])
|
|||
WCMD_free_commands(toExecute);
|
||||
toExecute = NULL;
|
||||
|
||||
HeapFree(GetProcessHeap(), 0, cmd);
|
||||
heap_free(cmd);
|
||||
return errorlevel;
|
||||
}
|
||||
|
||||
|
@ -2647,7 +2647,7 @@ int wmain (int argc, WCHAR *argvW[])
|
|||
WCMD_process_commands(toExecute, FALSE, FALSE);
|
||||
WCMD_free_commands(toExecute);
|
||||
toExecute = NULL;
|
||||
HeapFree(GetProcessHeap(), 0, cmd);
|
||||
heap_free(cmd);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue