cmd: Avoid naming conflicts with the global HeapAlloc wrappers.
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
37fce36989
commit
44bda237ed
|
@ -257,7 +257,7 @@ WCHAR *WCMD_fgets(WCHAR *buf, DWORD noChars, HANDLE h)
|
|||
const char *p;
|
||||
|
||||
cp = GetConsoleCP();
|
||||
bufA = heap_alloc(noChars);
|
||||
bufA = heap_xalloc(noChars);
|
||||
|
||||
/* Save current file position */
|
||||
filepos.QuadPart = 0;
|
||||
|
@ -508,7 +508,7 @@ void WCMD_HandleTildaModifiers(WCHAR **start, BOOL atExecute)
|
|||
|
||||
size = GetEnvironmentVariableW(env, NULL, 0);
|
||||
if (size > 0) {
|
||||
WCHAR *fullpath = heap_alloc(size * sizeof(WCHAR));
|
||||
WCHAR *fullpath = heap_xalloc(size * sizeof(WCHAR));
|
||||
if (!fullpath || (GetEnvironmentVariableW(env, fullpath, size) == 0) ||
|
||||
(SearchPathW(fullpath, outputparam, NULL, MAX_PATH, outputparam, NULL) == 0))
|
||||
size = 0;
|
||||
|
|
|
@ -720,7 +720,7 @@ void WCMD_copy(WCHAR * args) {
|
|||
}
|
||||
|
||||
/* We have found something to process - build a COPY_FILE block to store it */
|
||||
thiscopy = heap_alloc(sizeof(COPY_FILES));
|
||||
thiscopy = heap_xalloc(sizeof(COPY_FILES));
|
||||
|
||||
WINE_TRACE("Not a switch, but probably a filename/list %s\n", wine_dbgstr_w(thisparam));
|
||||
thiscopy->concatenate = concatnextfilename;
|
||||
|
@ -731,7 +731,7 @@ void WCMD_copy(WCHAR * args) {
|
|||
leave space to append \* to the end) , then copy in character by character. Strip off
|
||||
quotes if we find them. */
|
||||
len = strlenW(thisparam) + (sizeof(WCHAR) * 5); /* 5 spare characters, null + \*.* */
|
||||
thiscopy->name = heap_alloc(len*sizeof(WCHAR));
|
||||
thiscopy->name = heap_xalloc(len*sizeof(WCHAR));
|
||||
memset(thiscopy->name, 0x00, len);
|
||||
|
||||
pos1 = thisparam;
|
||||
|
@ -810,7 +810,7 @@ void WCMD_copy(WCHAR * args) {
|
|||
strcpyW(destname, dotW);
|
||||
strcatW(destname, slashW);
|
||||
|
||||
destination = heap_alloc(sizeof(COPY_FILES));
|
||||
destination = heap_xalloc(sizeof(COPY_FILES));
|
||||
if (destination == NULL) goto exitreturn;
|
||||
destination->concatenate = FALSE; /* Not used for destination */
|
||||
destination->binarycopy = binarymode;
|
||||
|
@ -1390,7 +1390,7 @@ static BOOL WCMD_delete_one (const WCHAR *thisArg) {
|
|||
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(subParm));
|
||||
|
||||
/* Allocate memory, add to list */
|
||||
nextDir = heap_alloc(sizeof(DIRECTORY_STACK));
|
||||
nextDir = heap_xalloc(sizeof(DIRECTORY_STACK));
|
||||
if (allDirs == NULL) allDirs = nextDir;
|
||||
if (lastEntry != NULL) lastEntry->next = nextDir;
|
||||
lastEntry = nextDir;
|
||||
|
@ -1476,7 +1476,7 @@ static WCHAR *WCMD_strtrim(const WCHAR *s)
|
|||
const WCHAR *start = s;
|
||||
WCHAR* result;
|
||||
|
||||
result = heap_alloc((len + 1) * sizeof(WCHAR));
|
||||
result = heap_xalloc((len + 1) * sizeof(WCHAR));
|
||||
|
||||
while (isspaceW(*start)) start++;
|
||||
if (*start) {
|
||||
|
@ -1787,12 +1787,12 @@ static void WCMD_add_dirstowalk(DIRECTORY_STACK *dirsToWalk) {
|
|||
(strcmpW(fd.cFileName, dotW) != 0))
|
||||
{
|
||||
/* Allocate memory, add to list */
|
||||
DIRECTORY_STACK *toWalk = heap_alloc(sizeof(DIRECTORY_STACK));
|
||||
DIRECTORY_STACK *toWalk = heap_xalloc(sizeof(DIRECTORY_STACK));
|
||||
WINE_TRACE("(%p->%p)\n", remainingDirs, remainingDirs->next);
|
||||
toWalk->next = remainingDirs->next;
|
||||
remainingDirs->next = toWalk;
|
||||
remainingDirs = toWalk;
|
||||
toWalk->dirName = heap_alloc(sizeof(WCHAR) * (strlenW(dirsToWalk->dirName) + 2 + strlenW(fd.cFileName)));
|
||||
toWalk->dirName = heap_xalloc(sizeof(WCHAR) * (strlenW(dirsToWalk->dirName) + 2 + strlenW(fd.cFileName)));
|
||||
strcpyW(toWalk->dirName, dirsToWalk->dirName);
|
||||
strcatW(toWalk->dirName, slashW);
|
||||
strcatW(toWalk->dirName, fd.cFileName);
|
||||
|
@ -2228,7 +2228,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
|
|||
/* Set up the list of directories to recurse if we are going to */
|
||||
} else if (doRecurse) {
|
||||
/* Allocate memory, add to list */
|
||||
dirsToWalk = heap_alloc(sizeof(DIRECTORY_STACK));
|
||||
dirsToWalk = heap_xalloc(sizeof(DIRECTORY_STACK));
|
||||
dirsToWalk->next = NULL;
|
||||
dirsToWalk->dirName = heap_strdupW(optionsRoot);
|
||||
WINE_TRACE("Starting with root directory %s\n", wine_dbgstr_w(dirsToWalk->dirName));
|
||||
|
@ -3673,7 +3673,7 @@ static int WCMD_getprecedence(const WCHAR in)
|
|||
* stack
|
||||
*/
|
||||
static void WCMD_pushnumber(WCHAR *var, int num, VARSTACK **varstack) {
|
||||
VARSTACK *thisstack = heap_alloc(sizeof(VARSTACK));
|
||||
VARSTACK *thisstack = heap_xalloc(sizeof(VARSTACK));
|
||||
thisstack->isnum = (var == NULL);
|
||||
if (var) {
|
||||
thisstack->variable = var;
|
||||
|
@ -3736,7 +3736,7 @@ static int WCMD_popnumber(VARSTACK **varstack) {
|
|||
* Push an operator onto the supplied stack
|
||||
*/
|
||||
static void WCMD_pushoperator(WCHAR op, int precedence, OPSTACK **opstack) {
|
||||
OPSTACK *thisstack = heap_alloc(sizeof(OPSTACK));
|
||||
OPSTACK *thisstack = heap_xalloc(sizeof(OPSTACK));
|
||||
thisstack->precedence = precedence;
|
||||
thisstack->op = op;
|
||||
thisstack->next = *opstack;
|
||||
|
@ -4206,7 +4206,7 @@ void WCMD_setshow_env (WCHAR *s) {
|
|||
WCHAR *src,*dst;
|
||||
|
||||
/* Remove all quotes before doing any calculations */
|
||||
thisexpr = heap_alloc((strlenW(s+2)+1) * sizeof(WCHAR));
|
||||
thisexpr = heap_xalloc((strlenW(s+2)+1) * sizeof(WCHAR));
|
||||
src = s+2;
|
||||
dst = thisexpr;
|
||||
while (*src) {
|
||||
|
@ -4407,7 +4407,7 @@ void WCMD_start(WCHAR *args)
|
|||
|
||||
GetWindowsDirectoryW( file, MAX_PATH );
|
||||
strcatW( file, exeW );
|
||||
cmdline = heap_alloc( (strlenW(file) + strlenW(args) + 8) * sizeof(WCHAR) );
|
||||
cmdline = heap_xalloc( (strlenW(file) + strlenW(args) + 8) * sizeof(WCHAR) );
|
||||
strcpyW( cmdline, file );
|
||||
strcatW( cmdline, spaceW );
|
||||
cmdline_params = cmdline + strlenW(cmdline);
|
||||
|
|
|
@ -203,7 +203,7 @@ static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
|
|||
ULONG domainLen = MAXSTRING;
|
||||
SID_NAME_USE nameuse;
|
||||
|
||||
secBuffer = heap_alloc(sizeNeeded * sizeof(BYTE));
|
||||
secBuffer = heap_xalloc(sizeNeeded * sizeof(BYTE));
|
||||
|
||||
/* Get the owners security descriptor */
|
||||
if(!GetFileSecurityW(filename, OWNER_SECURITY_INFORMATION, secBuffer,
|
||||
|
@ -273,7 +273,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
|||
same directory. Note issuing a directory header with no contents
|
||||
mirrors what windows does */
|
||||
parms = inputparms;
|
||||
fd = heap_alloc(sizeof(WIN32_FIND_DATAW));
|
||||
fd = heap_xalloc(sizeof(WIN32_FIND_DATAW));
|
||||
while (parms && strcmpW(inputparms->dirName, parms->dirName) == 0) {
|
||||
concurrentDirs++;
|
||||
|
||||
|
@ -510,7 +510,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
|
|||
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string));
|
||||
|
||||
/* Allocate memory, add to list */
|
||||
thisDir = heap_alloc(sizeof(DIRECTORY_STACK));
|
||||
thisDir = heap_xalloc(sizeof(DIRECTORY_STACK));
|
||||
if (dirStack == NULL) dirStack = thisDir;
|
||||
if (lastEntry != NULL) lastEntry->next = thisDir;
|
||||
lastEntry = thisDir;
|
||||
|
@ -841,7 +841,7 @@ void WCMD_directory (WCHAR *args)
|
|||
}
|
||||
|
||||
WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));
|
||||
thisEntry = heap_alloc(sizeof(DIRECTORY_STACK));
|
||||
thisEntry = heap_xalloc(sizeof(DIRECTORY_STACK));
|
||||
if (fullParms == NULL) fullParms = thisEntry;
|
||||
if (prevEntry != NULL) prevEntry->next = thisEntry;
|
||||
prevEntry = thisEntry;
|
||||
|
@ -853,11 +853,11 @@ void WCMD_directory (WCHAR *args)
|
|||
wine_dbgstr_w(drive), wine_dbgstr_w(dir),
|
||||
wine_dbgstr_w(fname), wine_dbgstr_w(ext));
|
||||
|
||||
thisEntry->dirName = heap_alloc(sizeof(WCHAR) * (strlenW(drive)+strlenW(dir)+1));
|
||||
thisEntry->dirName = heap_xalloc(sizeof(WCHAR) * (strlenW(drive)+strlenW(dir)+1));
|
||||
strcpyW(thisEntry->dirName, drive);
|
||||
strcatW(thisEntry->dirName, dir);
|
||||
|
||||
thisEntry->fileName = heap_alloc(sizeof(WCHAR) * (strlenW(fname)+strlenW(ext)+1));
|
||||
thisEntry->fileName = heap_xalloc(sizeof(WCHAR) * (strlenW(fname)+strlenW(ext)+1));
|
||||
strcpyW(thisEntry->fileName, fname);
|
||||
strcatW(thisEntry->fileName, ext);
|
||||
|
||||
|
@ -867,7 +867,7 @@ void WCMD_directory (WCHAR *args)
|
|||
/* If just 'dir' entered, a '*' parameter is assumed */
|
||||
if (fullParms == NULL) {
|
||||
WINE_TRACE("Inserting default '*'\n");
|
||||
fullParms = heap_alloc(sizeof(DIRECTORY_STACK));
|
||||
fullParms = heap_xalloc(sizeof(DIRECTORY_STACK));
|
||||
fullParms->next = NULL;
|
||||
fullParms->dirName = heap_strdupW(cwd);
|
||||
fullParms->fileName = heap_strdupW(starW);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
#include <wine/heap.h>
|
||||
#include <wine/unicode.h>
|
||||
|
||||
/* msdn specified max for Win XP */
|
||||
|
@ -127,12 +128,7 @@ void WCMD_free_commands(CMD_LIST *cmds);
|
|||
void WCMD_execute (const WCHAR *orig_command, const WCHAR *redirects,
|
||||
CMD_LIST **cmdList, BOOL retrycall);
|
||||
|
||||
void *heap_alloc(size_t);
|
||||
|
||||
static inline BOOL heap_free(void *mem)
|
||||
{
|
||||
return HeapFree(GetProcessHeap(), 0, mem);
|
||||
}
|
||||
void *heap_xalloc(size_t);
|
||||
|
||||
static inline WCHAR *heap_strdupW(const WCHAR *str)
|
||||
{
|
||||
|
@ -142,7 +138,7 @@ static inline WCHAR *heap_strdupW(const WCHAR *str)
|
|||
size_t size;
|
||||
|
||||
size = (strlenW(str)+1)*sizeof(WCHAR);
|
||||
ret = heap_alloc(size);
|
||||
ret = heap_xalloc(size);
|
||||
memcpy(ret, str, size);
|
||||
}
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ static char *get_file_buffer(void)
|
|||
{
|
||||
static char *output_bufA = NULL;
|
||||
if (!output_bufA)
|
||||
output_bufA = heap_alloc(MAX_WRITECONSOLE_SIZE);
|
||||
output_bufA = heap_xalloc(MAX_WRITECONSOLE_SIZE);
|
||||
return output_bufA;
|
||||
}
|
||||
|
||||
|
@ -438,11 +438,11 @@ static void WCMD_show_prompt (BOOL newLine) {
|
|||
WCMD_output_asis (out_string);
|
||||
}
|
||||
|
||||
void *heap_alloc(size_t size)
|
||||
void *heap_xalloc(size_t size)
|
||||
{
|
||||
void *ret;
|
||||
|
||||
ret = HeapAlloc(GetProcessHeap(), 0, size);
|
||||
ret = heap_alloc(size);
|
||||
if(!ret) {
|
||||
ERR("Out of memory\n");
|
||||
ExitProcess(1);
|
||||
|
@ -981,7 +981,7 @@ static void init_msvcrt_io_block(STARTUPINFOW* st)
|
|||
* its new input & output handles)
|
||||
*/
|
||||
sz = max(sizeof(unsigned) + (sizeof(char) + sizeof(HANDLE)) * 3, st_p.cbReserved2);
|
||||
ptr = heap_alloc(sz);
|
||||
ptr = heap_xalloc(sz);
|
||||
flags = (char*)(ptr + sizeof(unsigned));
|
||||
handles = (HANDLE*)(flags + num * sizeof(char));
|
||||
|
||||
|
@ -1300,12 +1300,12 @@ void WCMD_execute (const WCHAR *command, const WCHAR *redirects,
|
|||
wine_dbgstr_w(command), cmdList);
|
||||
|
||||
/* Move copy of the command onto the heap so it can be expanded */
|
||||
new_cmd = heap_alloc(MAXSTRING * sizeof(WCHAR));
|
||||
new_cmd = heap_xalloc(MAXSTRING * sizeof(WCHAR));
|
||||
strcpyW(new_cmd, command);
|
||||
cmd = new_cmd;
|
||||
|
||||
/* Move copy of the redirects onto the heap so it can be expanded */
|
||||
new_redir = heap_alloc(MAXSTRING * sizeof(WCHAR));
|
||||
new_redir = heap_xalloc(MAXSTRING * sizeof(WCHAR));
|
||||
redir = new_redir;
|
||||
|
||||
/* Strip leading whitespaces, and a '@' if supplied */
|
||||
|
@ -1708,16 +1708,16 @@ static void WCMD_addCommand(WCHAR *command, int *commandLen,
|
|||
CMD_LIST *thisEntry = NULL;
|
||||
|
||||
/* Allocate storage for command */
|
||||
thisEntry = heap_alloc(sizeof(CMD_LIST));
|
||||
thisEntry = heap_xalloc(sizeof(CMD_LIST));
|
||||
|
||||
/* Copy in the command */
|
||||
if (command) {
|
||||
thisEntry->command = heap_alloc((*commandLen+1) * sizeof(WCHAR));
|
||||
thisEntry->command = heap_xalloc((*commandLen+1) * sizeof(WCHAR));
|
||||
memcpy(thisEntry->command, command, *commandLen * sizeof(WCHAR));
|
||||
thisEntry->command[*commandLen] = 0x00;
|
||||
|
||||
/* Copy in the redirects */
|
||||
thisEntry->redirects = heap_alloc((*redirLen+1) * sizeof(WCHAR));
|
||||
thisEntry->redirects = heap_xalloc((*redirLen+1) * sizeof(WCHAR));
|
||||
memcpy(thisEntry->redirects, redirs, *redirLen * sizeof(WCHAR));
|
||||
thisEntry->redirects[*redirLen] = 0x00;
|
||||
thisEntry->pipeFile[0] = 0x00;
|
||||
|
@ -1849,7 +1849,7 @@ WCHAR *WCMD_ReadAndParseLine(const WCHAR *optionalcmd, CMD_LIST **output, HANDLE
|
|||
|
||||
/* Allocate working space for a command read from keyboard, file etc */
|
||||
if (!extraSpace)
|
||||
extraSpace = heap_alloc((MAXSTRING+1) * sizeof(WCHAR));
|
||||
extraSpace = heap_xalloc((MAXSTRING+1) * sizeof(WCHAR));
|
||||
if (!extraSpace)
|
||||
{
|
||||
WINE_ERR("Could not allocate memory for extraSpace\n");
|
||||
|
|
Loading…
Reference in New Issue