Author: weiden
Date: Wed Aug 1 14:17:13 2007
New Revision: 28065
URL:
http://svn.reactos.org/svn/reactos?rev=28065&view=rev
Log:
- Add code to detect buffer overflows and buffer underflows on memory operations. This
code is only enabled if _DEBUG is defined.
- Change all calls to malloc, realloc and free to cmd_alloc, cmd_realloc and cmd_free
Added:
trunk/reactos/base/shell/cmd/cmddbg.c (with props)
trunk/reactos/base/shell/cmd/cmddbg.h (with props)
Modified:
trunk/reactos/base/shell/cmd/alias.c
trunk/reactos/base/shell/cmd/attrib.c
trunk/reactos/base/shell/cmd/batch.c
trunk/reactos/base/shell/cmd/beep.c
trunk/reactos/base/shell/cmd/call.c
trunk/reactos/base/shell/cmd/chcp.c
trunk/reactos/base/shell/cmd/choice.c
trunk/reactos/base/shell/cmd/cls.c
trunk/reactos/base/shell/cmd/cmd.c
trunk/reactos/base/shell/cmd/cmd.h
trunk/reactos/base/shell/cmd/cmd.rbuild
trunk/reactos/base/shell/cmd/cmdinput.c
trunk/reactos/base/shell/cmd/cmdtable.c
trunk/reactos/base/shell/cmd/color.c
trunk/reactos/base/shell/cmd/console.c
trunk/reactos/base/shell/cmd/copy.c
trunk/reactos/base/shell/cmd/date.c
trunk/reactos/base/shell/cmd/del.c
trunk/reactos/base/shell/cmd/delay.c
trunk/reactos/base/shell/cmd/dir.c
trunk/reactos/base/shell/cmd/dirstack.c
trunk/reactos/base/shell/cmd/echo.c
trunk/reactos/base/shell/cmd/error.c
trunk/reactos/base/shell/cmd/filecomp.c
trunk/reactos/base/shell/cmd/for.c
trunk/reactos/base/shell/cmd/free.c
trunk/reactos/base/shell/cmd/goto.c
trunk/reactos/base/shell/cmd/history.c
trunk/reactos/base/shell/cmd/if.c
trunk/reactos/base/shell/cmd/internal.c
trunk/reactos/base/shell/cmd/label.c
trunk/reactos/base/shell/cmd/locale.c
trunk/reactos/base/shell/cmd/main.c
trunk/reactos/base/shell/cmd/memory.c
trunk/reactos/base/shell/cmd/misc.c
trunk/reactos/base/shell/cmd/move.c
trunk/reactos/base/shell/cmd/msgbox.c
trunk/reactos/base/shell/cmd/path.c
trunk/reactos/base/shell/cmd/pause.c
trunk/reactos/base/shell/cmd/precomp.h
trunk/reactos/base/shell/cmd/prompt.c
trunk/reactos/base/shell/cmd/ren.c
trunk/reactos/base/shell/cmd/screen.c
trunk/reactos/base/shell/cmd/set.c
trunk/reactos/base/shell/cmd/shift.c
trunk/reactos/base/shell/cmd/start.c
trunk/reactos/base/shell/cmd/time.c
trunk/reactos/base/shell/cmd/timer.c
trunk/reactos/base/shell/cmd/title.c
trunk/reactos/base/shell/cmd/type.c
trunk/reactos/base/shell/cmd/ver.c
trunk/reactos/base/shell/cmd/verify.c
trunk/reactos/base/shell/cmd/vol.c
trunk/reactos/base/shell/cmd/where.c
trunk/reactos/base/shell/cmd/window.c
Modified: trunk/reactos/base/shell/cmd/alias.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/alias.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/alias.c (original)
+++ trunk/reactos/base/shell/cmd/alias.c Wed Aug 1 14:17:13 2007
@@ -31,7 +31,6 @@
#include <precomp.h>
-#include "resource.h"
#ifdef FEATURE_ALIASES
@@ -89,9 +88,9 @@
prev->next = ptr->next;
else
lpFirst = ptr->next;
- free (ptr->lpName);
- free (ptr->lpSubst);
- free (ptr);
+ cmd_free (ptr->lpName);
+ cmd_free (ptr->lpSubst);
+ cmd_free (ptr);
return;
}
prev = ptr;
@@ -111,14 +110,14 @@
{
if (!_tcsicmp (ptr->lpName, name))
{
- s = (LPTSTR)malloc ((_tcslen (subst) + 1)*sizeof(TCHAR));
+ s = (LPTSTR)cmd_alloc ((_tcslen (subst) + 1)*sizeof(TCHAR));
if (!s)
{
error_out_of_memory ();
return;
}
- free (ptr->lpSubst);
+ cmd_free (ptr->lpSubst);
ptr->lpSubst = s;
_tcscpy (ptr->lpSubst, subst);
return;
@@ -126,27 +125,27 @@
ptr = ptr->next;
}
- ptr = (LPALIAS)malloc (sizeof (ALIAS));
+ ptr = (LPALIAS)cmd_alloc (sizeof (ALIAS));
if (!ptr)
return;
ptr->next = 0;
- ptr->lpName = (LPTSTR)malloc ((_tcslen (name) + 1)*sizeof(TCHAR));
+ ptr->lpName = (LPTSTR)cmd_alloc ((_tcslen (name) + 1)*sizeof(TCHAR));
if (!ptr->lpName)
{
error_out_of_memory ();
- free (ptr);
+ cmd_free (ptr);
return;
}
_tcscpy (ptr->lpName, name);
- ptr->lpSubst = (LPTSTR)malloc ((_tcslen (subst) + 1)*sizeof(TCHAR));
+ ptr->lpSubst = (LPTSTR)cmd_alloc ((_tcslen (subst) + 1)*sizeof(TCHAR));
if (!ptr->lpSubst)
{
error_out_of_memory ();
- free (ptr->lpName);
- free (ptr);
+ cmd_free (ptr->lpName);
+ cmd_free (ptr);
return;
}
_tcscpy (ptr->lpSubst, subst);
@@ -220,14 +219,14 @@
lpLast = lpFirst;
lpFirst = lpLast->next;
- free (lpLast->lpName);
- free (lpLast->lpSubst);
- free (lpLast);
+ cmd_free (lpLast->lpName);
+ cmd_free (lpLast->lpSubst);
+ cmd_free (lpLast);
}
- free (lpFirst->lpName);
- free (lpFirst->lpSubst);
- free (lpFirst);
+ cmd_free (lpFirst->lpName);
+ cmd_free (lpFirst->lpSubst);
+ cmd_free (lpFirst);
lpFirst = NULL;
lpLast = NULL;
Modified: trunk/reactos/base/shell/cmd/attrib.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/attrib.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/attrib.c (original)
+++ trunk/reactos/base/shell/cmd/attrib.c Wed Aug 1 14:17:13 2007
@@ -33,7 +33,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_ATTRIB
Modified: trunk/reactos/base/shell/cmd/batch.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/batch.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/batch.c (original)
+++ trunk/reactos/base/shell/cmd/batch.c Wed Aug 1 14:17:13 2007
@@ -39,7 +39,7 @@
* Implementation of FOR command
*
* 20-Jul-1998 (John P Price <linux-guru(a)gcfl.net>)
- * added error checking after malloc calls
+ * added error checking after cmd_alloc calls
*
* 27-Jul-1998 (John P Price <linux-guru(a)gcfl.net>)
* added config.h include
@@ -59,7 +59,6 @@
*/
#include <precomp.h>
-#include "resource.h"
/* The stack of current batch contexts.
@@ -114,7 +113,7 @@
LPTSTR BatchParams (LPTSTR s1, LPTSTR s2)
{
- LPTSTR dp = (LPTSTR)malloc ((_tcslen(s1) + _tcslen(s2) + 3) * sizeof (TCHAR));
+ LPTSTR dp = (LPTSTR)cmd_alloc ((_tcslen(s1) + _tcslen(s2) + 3) * sizeof (TCHAR));
/* JPP 20-Jul-1998 added error checking */
if (dp == NULL)
@@ -188,19 +187,19 @@
}
if (bc->params)
- free(bc->params);
+ cmd_free(bc->params);
if (bc->forproto)
- free(bc->forproto);
+ cmd_free(bc->forproto);
if (bc->ffind)
- free(bc->ffind);
+ cmd_free(bc->ffind);
/* Preserve echo state across batch calls */
bEcho = bc->bEcho;
bc = bc->prev;
- free(t);
+ cmd_free(t);
}
if (msg && *msg)
@@ -241,7 +240,7 @@
if (bc == NULL)
{
/* No curent batch file, create a new context */
- LPBATCH_CONTEXT n = (LPBATCH_CONTEXT)malloc (sizeof(BATCH_CONTEXT));
+ LPBATCH_CONTEXT n = (LPBATCH_CONTEXT)cmd_alloc (sizeof(BATCH_CONTEXT));
if (n == NULL)
{
@@ -260,7 +259,7 @@
/* Then we are transferring to another batch */
CloseHandle (bc->hBatchFile);
bc->hBatchFile = INVALID_HANDLE_VALUE;
- free (bc->params);
+ cmd_free (bc->params);
}
bc->hBatchFile = hFile;
@@ -275,7 +274,7 @@
//
// Allocate enough memory to hold the params and copy them over without
modifications
//
- bc->raw_params = (TCHAR*) malloc((_tcslen(param)+1) * sizeof(TCHAR));
+ bc->raw_params = (TCHAR*) cmd_alloc((_tcslen(param)+1) * sizeof(TCHAR));
if (bc->raw_params != NULL)
{
memset (bc->raw_params, 0, _tcslen(bc->raw_params) * sizeof(TCHAR));
@@ -378,7 +377,7 @@
else
{
/* For first find, allocate a find first block */
- if ((bc->ffind = (LPWIN32_FIND_DATA)malloc (sizeof (WIN32_FIND_DATA))) == NULL)
+ if ((bc->ffind = (LPWIN32_FIND_DATA)cmd_alloc (sizeof (WIN32_FIND_DATA))) ==
NULL)
{
error_out_of_memory();
return NULL;
@@ -392,7 +391,7 @@
if (fv == NULL)
{
/* Null indicates no more files.. */
- free (bc->ffind); /* free the buffer */
+ cmd_free (bc->ffind); /* free the buffer */
bc->ffind = NULL;
bc->shiftlevel++; /* On to next list element */
continue;
Modified: trunk/reactos/base/shell/cmd/beep.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/beep.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/beep.c (original)
+++ trunk/reactos/base/shell/cmd/beep.c Wed Aug 1 14:17:13 2007
@@ -25,7 +25,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_BEEP
Modified: trunk/reactos/base/shell/cmd/call.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/call.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/call.c (original)
+++ trunk/reactos/base/shell/cmd/call.c Wed Aug 1 14:17:13 2007
@@ -29,7 +29,6 @@
*/
#include <precomp.h>
-#include "resource.h"
/*
@@ -56,7 +55,7 @@
nErrorLevel = 0;
- n = (LPBATCH_CONTEXT)malloc (sizeof (BATCH_CONTEXT));
+ n = (LPBATCH_CONTEXT)cmd_alloc (sizeof (BATCH_CONTEXT));
if (n == NULL)
{
@@ -91,7 +90,7 @@
if (bc->hBatchFile == INVALID_HANDLE_VALUE)
{
bc = bc->prev;
- free (n);
+ cmd_free (n);
}
return 0;
Modified: trunk/reactos/base/shell/cmd/chcp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/chcp.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/chcp.c (original)
+++ trunk/reactos/base/shell/cmd/chcp.c Wed Aug 1 14:17:13 2007
@@ -12,7 +12,6 @@
*/
#include <precomp.h>
-#include "resource.h"
Modified: trunk/reactos/base/shell/cmd/choice.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/choice.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/choice.c (original)
+++ trunk/reactos/base/shell/cmd/choice.c Wed Aug 1 14:17:13 2007
@@ -20,7 +20,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_CHOICE
Modified: trunk/reactos/base/shell/cmd/cls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cls.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/cls.c (original)
+++ trunk/reactos/base/shell/cmd/cls.c Wed Aug 1 14:17:13 2007
@@ -27,7 +27,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_CLS
Modified: trunk/reactos/base/shell/cmd/cmd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.c (original)
+++ trunk/reactos/base/shell/cmd/cmd.c Wed Aug 1 14:17:13 2007
@@ -142,8 +142,6 @@
*/
#include <precomp.h>
-#include <malloc.h>
-#include "resource.h"
#ifndef NT_SUCCESS
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
@@ -351,10 +349,10 @@
#endif
/* we need biger buffer that First, Rest, Full are already
- need rewrite some code to use realloc when it need instead
+ need rewrite some code to use cmd_realloc when it need instead
of add 512bytes extra */
- first = malloc ( (_tcslen(First) + 512) * sizeof(TCHAR));
+ first = cmd_alloc ( (_tcslen(First) + 512) * sizeof(TCHAR));
if (first == NULL)
{
error_out_of_memory();
@@ -362,31 +360,31 @@
return ;
}
- rest = malloc ( (_tcslen(Rest) + 512) * sizeof(TCHAR));
+ rest = cmd_alloc ( (_tcslen(Rest) + 512) * sizeof(TCHAR));
if (rest == NULL)
{
- free (first);
+ cmd_free (first);
error_out_of_memory();
nErrorLevel = 1;
return ;
}
- full = malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
+ full = cmd_alloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
if (full == NULL)
{
- free (first);
- free (rest);
+ cmd_free (first);
+ cmd_free (rest);
error_out_of_memory();
nErrorLevel = 1;
return ;
}
- szFullName = malloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
+ szFullName = cmd_alloc ( (_tcslen(Full) + 512) * sizeof(TCHAR));
if (full == NULL)
{
- free (first);
- free (rest);
- free (full);
+ cmd_free (first);
+ cmd_free (rest);
+ cmd_free (full);
error_out_of_memory();
nErrorLevel = 1;
return ;
@@ -455,10 +453,10 @@
if (!working) ConErrResPuts (STRING_FREE_ERROR1);
- free (first);
- free (rest);
- free (full);
- free (szFullName);
+ cmd_free (first);
+ cmd_free (rest);
+ cmd_free (full);
+ cmd_free (szFullName);
nErrorLevel = 1;
return;
}
@@ -468,10 +466,10 @@
if (!SearchForExecutable (first, szFullName))
{
error_bad_command ();
- free (first);
- free (rest);
- free (full);
- free (szFullName);
+ cmd_free (first);
+ cmd_free (rest);
+ cmd_free (full);
+ cmd_free (szFullName);
nErrorLevel = 1;
return;
@@ -572,10 +570,10 @@
OutputCodePage = GetConsoleOutputCP();
SetConsoleTitle (szWindowTitle);
- free(first);
- free(rest);
- free(full);
- free (szFullName);
+ cmd_free(first);
+ cmd_free(rest);
+ cmd_free(full);
+ cmd_free (szFullName);
}
@@ -602,7 +600,7 @@
DebugPrintf (_T("DoCommand: (\'%s\')\n"), line);
#endif /* DEBUG */
- com = malloc( (_tcslen(line) +512)*sizeof(TCHAR) );
+ com = cmd_alloc( (_tcslen(line) +512)*sizeof(TCHAR) );
if (com == NULL)
{
error_out_of_memory();
@@ -646,7 +644,7 @@
if(_tcslen(com) > MAX_PATH)
{
error_bad_command();
- free(com);
+ cmd_free(com);
return;
}
*/
@@ -700,7 +698,7 @@
}
}
}
- free(com);
+ cmd_free(com);
}
@@ -1124,8 +1122,8 @@
return TRUE;
*retlen = needed;
if ( *ret )
- free ( *ret );
- *ret = (LPTSTR)malloc ( *retlen * sizeof(TCHAR) );
+ cmd_free ( *ret );
+ *ret = (LPTSTR)cmd_alloc ( *retlen * sizeof(TCHAR) );
if ( !*ret )
SetLastError ( ERROR_OUTOFMEMORY );
return *ret != NULL;
Modified: trunk/reactos/base/shell/cmd/cmd.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.h?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.h (original)
+++ trunk/reactos/base/shell/cmd/cmd.h Wed Aug 1 14:17:13 2007
@@ -30,6 +30,8 @@
#include <tchar.h>
#include "cmdver.h"
+
+#include "cmddbg.h"
#define BREAK_BATCHFILE 1
#define BREAK_OUTOFBATCH 2
Modified: trunk/reactos/base/shell/cmd/cmd.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmd.rbuild?…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmd.rbuild (original)
+++ trunk/reactos/base/shell/cmd/cmd.rbuild Wed Aug 1 14:17:13 2007
@@ -17,6 +17,7 @@
<file>choice.c</file>
<file>cls.c</file>
<file>cmd.c</file>
+ <file>cmddbg.c</file>
<file>cmdinput.c</file>
<file>cmdtable.c</file>
<file>color.c</file>
Added: trunk/reactos/base/shell/cmd/cmddbg.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmddbg.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmddbg.c (added)
+++ trunk/reactos/base/shell/cmd/cmddbg.c Wed Aug 1 14:17:13 2007
@@ -1,0 +1,140 @@
+#include <precomp.h>
+
+#ifdef _DEBUG
+
+#define REDZONE_SIZE 32
+#define REDZONE_LEFT 0x78
+#define REDZONE_RIGHT 0x87
+
+typedef struct
+{
+ size_t size;
+ const char *file;
+ int line;
+} alloc_info, *palloc_info;
+
+static void *
+get_base_ptr(void *ptr)
+{
+ return (void *)((UINT_PTR)ptr - REDZONE_SIZE - sizeof(alloc_info));
+}
+
+static void *
+write_redzone(void *ptr, size_t size, const char *file, int line)
+{
+ void *ret;
+ palloc_info info = (palloc_info)ptr;
+
+ info->size = size;
+ info->file = file;
+ info->line = line;
+
+ ptr = (void *)(info + 1);
+ memset(ptr, REDZONE_LEFT, REDZONE_SIZE);
+ ret = (void *)((size_t)ptr + REDZONE_SIZE);
+ ptr = (void *)((size_t)ret + size);
+ memset(ptr, REDZONE_RIGHT, REDZONE_SIZE);
+ return ret;
+}
+
+static int
+check_redzone_region(void *ptr, unsigned char sig, void **newptr)
+{
+ unsigned char *p, *q;
+ int ret = 1;
+
+ p = (unsigned char *)ptr;
+ q = p + REDZONE_SIZE;
+ while (p != q)
+ {
+ if (*(p++) != sig)
+ ret = 0;
+ }
+
+ if (newptr != NULL)
+ *newptr = p;
+ return ret;
+}
+
+static void
+redzone_err(const char *msg, palloc_info info, void *ptr, const char *file, int line)
+{
+ DbgPrint("CMD: %s\n", msg);
+ DbgPrint(" Block: 0x%p Size: %lu\n", ptr, info->size);
+ DbgPrint(" Allocated from %s:%d\n", info->file, info->line);
+ DbgPrint(" Called from: %s:%d\n", file, line);
+ ExitProcess(1);
+}
+
+static void
+check_redzone(void *ptr, const char *file, int line)
+{
+ palloc_info info = (palloc_info)ptr;
+ ptr = (void *)(info + 1);
+ if (!check_redzone_region(ptr, REDZONE_LEFT, &ptr))
+ redzone_err("Detected buffer underflow!", info, ptr, file, line);
+ ptr = (void *)((UINT_PTR)ptr + info->size);
+ if (!check_redzone_region(ptr, REDZONE_RIGHT, NULL))
+ redzone_err("Detected buffer overflow!", info, ptr, file, line);
+}
+
+static size_t
+calculate_size_with_redzone(size_t size)
+{
+ return sizeof(alloc_info) + size + (2 * REDZONE_SIZE);
+}
+
+void *
+cmd_alloc_dbg(size_t size, const char *file, int line)
+{
+ void *newptr = NULL;
+
+ newptr = malloc(calculate_size_with_redzone(size));
+ if (newptr != NULL)
+ newptr = write_redzone(newptr, size, file, line);
+
+ return newptr;
+}
+
+void *
+cmd_realloc_dbg(void *ptr, size_t size, const char *file, int line)
+{
+ void *newptr = NULL;
+
+ if (ptr == NULL)
+ return cmd_alloc_dbg(size, file, line);
+ if (size == 0)
+ {
+ cmd_free_dbg(ptr, file, line);
+ return NULL;
+ }
+
+ ptr = get_base_ptr(ptr);
+ check_redzone(ptr, file, line);
+
+ newptr = realloc(ptr, calculate_size_with_redzone(size));
+ if (newptr != NULL)
+ newptr = write_redzone(newptr, size, file, line);
+
+ return newptr;
+}
+
+void
+cmd_free_dbg(void *ptr, const char *file, int line)
+{
+ if (ptr != NULL)
+ {
+ ptr = get_base_ptr(ptr);
+ check_redzone(ptr, file, line);
+ }
+
+ free(ptr);
+}
+
+void
+cmd_exit(int code)
+{
+ ExitProcess(code);
+}
+
+#endif /* _DEBUG */
Propchange: trunk/reactos/base/shell/cmd/cmddbg.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/base/shell/cmd/cmddbg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmddbg.h?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmddbg.h (added)
+++ trunk/reactos/base/shell/cmd/cmddbg.h Wed Aug 1 14:17:13 2007
@@ -1,0 +1,22 @@
+#ifdef _DEBUG
+
+#define cmd_alloc(size) cmd_alloc_dbg(size, __FILE__, __LINE__)
+#define cmd_realloc(ptr,size) cmd_realloc_dbg(ptr, size, __FILE__, __LINE__)
+#define cmd_free(ptr) cmd_free_dbg(ptr, __FILE__, __LINE__)
+
+void *
+cmd_alloc_dbg(size_t size, const char *file, int line);
+
+void *
+cmd_realloc_dbg(void *ptr, size_t size, const char *file, int line);
+
+void
+cmd_free_dbg(void *ptr, const char *file, int line);
+
+#else
+
+#define cmd_alloc(size) malloc(size)
+#define cmd_realloc(ptr,size) realloc(ptr, size)
+#define cmd_free(ptr) free(ptr)
+
+#endif
Propchange: trunk/reactos/base/shell/cmd/cmddbg.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/base/shell/cmd/cmdinput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmdinput.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmdinput.c (original)
+++ trunk/reactos/base/shell/cmd/cmdinput.c Wed Aug 1 14:17:13 2007
@@ -98,7 +98,6 @@
*/
#include <precomp.h>
-#include "resource.h"
SHORT maxx;
Modified: trunk/reactos/base/shell/cmd/cmdtable.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/cmdtable.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/cmdtable.c (original)
+++ trunk/reactos/base/shell/cmd/cmdtable.c Wed Aug 1 14:17:13 2007
@@ -18,7 +18,6 @@
*/
#include <precomp.h>
-#include "resource.h"
/* a list of all the internal commands, associating their command names */
Modified: trunk/reactos/base/shell/cmd/color.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/color.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/color.c (original)
+++ trunk/reactos/base/shell/cmd/color.c Wed Aug 1 14:17:13 2007
@@ -21,7 +21,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_COLOR
Modified: trunk/reactos/base/shell/cmd/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/console.c?r…
==============================================================================
--- trunk/reactos/base/shell/cmd/console.c (original)
+++ trunk/reactos/base/shell/cmd/console.c Wed Aug 1 14:17:13 2007
@@ -17,10 +17,7 @@
* Fixed ConPrintfPaging
*/
-
-
#include <precomp.h>
-#include "resource.h"
#define OUTPUT_BUFFER_SIZE 4096
@@ -103,7 +100,7 @@
PCHAR pBuf;
#ifdef _UNICODE
- pBuf = (PCHAR)malloc(dwLength);
+ pBuf = (PCHAR)cmd_alloc(dwLength);
#else
pBuf = lpInput;
#endif
@@ -129,7 +126,7 @@
}
#ifdef _UNICODE
- free(pBuf);
+ cmd_free(pBuf);
#endif
SetConsoleMode (hFile, dwOldMode);
@@ -169,7 +166,7 @@
len = _tcslen(szText);
#ifdef _UNICODE
- pBuf = malloc(len + 1);
+ pBuf = cmd_alloc(len + 1);
len = WideCharToMultiByte( OutputCodePage, 0, szText, len + 1, pBuf, len + 1, NULL,
NULL) - 1;
#else
pBuf = szText;
@@ -185,7 +182,7 @@
&dwWritten,
NULL);
#ifdef _UNICODE
- free(pBuf);
+ cmd_free(pBuf);
#endif
}
@@ -219,7 +216,7 @@
len = _vstprintf (szOut, szFormat, arg_ptr);
#ifdef _UNICODE
- pBuf = malloc(len + 1);
+ pBuf = cmd_alloc(len + 1);
len = WideCharToMultiByte( OutputCodePage, 0, szOut, len + 1, pBuf, len + 1, NULL, NULL)
- 1;
#else
pBuf = szOut;
@@ -233,7 +230,7 @@
#ifdef _UNICODE
- free(pBuf);
+ cmd_free(pBuf);
#endif
}
@@ -287,7 +284,7 @@
len = _vstprintf (szOut, szFormat, arg_ptr);
#ifdef _UNICODE
- pBuf = malloc(len + 1);
+ pBuf = cmd_alloc(len + 1);
len = WideCharToMultiByte( OutputCodePage, 0, szOut, len + 1, pBuf, len + 1, NULL, NULL)
- 1;
#else
pBuf = szOut;
@@ -311,7 +308,7 @@
if(PagePrompt() != PROMPT_YES)
{
#ifdef _UNICODE
- free(pBuf);
+ cmd_free(pBuf);
#endif
return 1;
}
@@ -323,7 +320,7 @@
}
#ifdef _UNICODE
- free(pBuf);
+ cmd_free(pBuf);
#endif
return 0;
}
Modified: trunk/reactos/base/shell/cmd/copy.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/copy.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/copy.c (original)
+++ trunk/reactos/base/shell/cmd/copy.c Wed Aug 1 14:17:13 2007
@@ -32,7 +32,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_COPY
@@ -264,7 +263,7 @@
{
ConOutResPuts(STRING_COPY_ERROR3);
- free (buffer);
+ cmd_free (buffer);
CloseHandle (hFileDest);
CloseHandle (hFileSrc);
nErrorLevel = 1;
@@ -375,7 +374,7 @@
nErrorLevel = 0;
/* Get the envor value if it exists */
- evar = malloc(512 * sizeof(TCHAR));
+ evar = cmd_alloc(512 * sizeof(TCHAR));
if (evar==NULL) size = 0;
else
{
@@ -383,7 +382,7 @@
}
if (size > 512)
{
- evar = realloc(evar,size * sizeof(TCHAR) );
+ evar = cmd_realloc(evar,size * sizeof(TCHAR) );
if (evar!=NULL)
{
size = GetEnvironmentVariable (_T("COPYCMD"), evar, size);
@@ -449,7 +448,7 @@
}
}
}
- free(evar);
+ cmd_free(evar);
/*Split the user input into array*/
@@ -873,7 +872,7 @@
FindClose(hFile);
if (arg!=NULL)
- free(arg);
+ cmd_free(arg);
return 0;
}
Modified: trunk/reactos/base/shell/cmd/date.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/date.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/date.c (original)
+++ trunk/reactos/base/shell/cmd/date.c Wed Aug 1 14:17:13 2007
@@ -32,7 +32,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_DATE
Modified: trunk/reactos/base/shell/cmd/del.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/del.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/del.c (original)
+++ trunk/reactos/base/shell/cmd/del.c Wed Aug 1 14:17:13 2007
@@ -46,7 +46,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_DEL
Modified: trunk/reactos/base/shell/cmd/delay.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/delay.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/delay.c (original)
+++ trunk/reactos/base/shell/cmd/delay.c Wed Aug 1 14:17:13 2007
@@ -10,7 +10,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_DELAY
Modified: trunk/reactos/base/shell/cmd/dir.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/dir.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/dir.c (original)
+++ trunk/reactos/base/shell/cmd/dir.c Wed Aug 1 14:17:13 2007
@@ -135,7 +135,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_DIR
@@ -365,19 +364,19 @@
cCurSwitch = _T(' ');
if(ptrStart && ptrEnd)
{
- temp = malloc((ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
+ temp = cmd_alloc((ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
if(!temp)
return FALSE;
memcpy(temp, ptrStart, (ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
temp[(ptrEnd - ptrStart + 1)] = _T('\0');
if(!add_entry(entries, params, temp))
{
- free(temp);
+ cmd_free(temp);
freep(*params);
return FALSE;
}
- free(temp);
+ cmd_free(temp);
ptrStart = NULL;
ptrEnd = NULL;
@@ -397,19 +396,19 @@
/* Process a character for parameter */
if ((cCurSwitch == _T(' ')) && ptrStart && ptrEnd)
{
- temp = malloc((ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
+ temp = cmd_alloc((ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
if(!temp)
return FALSE;
memcpy(temp, ptrStart, (ptrEnd - ptrStart) + 2 * sizeof (TCHAR));
temp[(ptrEnd - ptrStart + 1)] = _T('\0');
if(!add_entry(entries, params, temp))
{
- free(temp);
+ cmd_free(temp);
freep(*params);
return FALSE;
}
- free(temp);
+ cmd_free(temp);
ptrStart = NULL;
ptrEnd = NULL;
@@ -568,19 +567,19 @@
/* Terminate the parameters */
if(ptrStart && ptrEnd)
{
- temp = malloc((ptrEnd - ptrStart + 2) * sizeof(TCHAR));
+ temp = cmd_alloc((ptrEnd - ptrStart + 2) * sizeof(TCHAR));
if(!temp)
return FALSE;
memcpy(temp, ptrStart, (ptrEnd - ptrStart + 1) * sizeof(TCHAR));
temp[(ptrEnd - ptrStart + 1)] = _T('\0');
if(!add_entry(entries, params, temp))
{
- free(temp);
+ cmd_free(temp);
freep(*params);
return FALSE;
}
- free(temp);
+ cmd_free(temp);
ptrStart = NULL;
ptrEnd = NULL;
@@ -1770,7 +1769,7 @@
_tcscat (szFullFileSpec, szFilespec);
/* Prepare the linked list, first node is allocated */
- ptrStartNode = malloc(sizeof(DIRFINDLISTNODE));
+ ptrStartNode = cmd_alloc(sizeof(DIRFINDLISTNODE));
if (ptrStartNode == NULL)
{
#ifdef _DEBUG
@@ -1790,7 +1789,7 @@
if ((wfdFileInfo.dwFileAttributes & lpFlags->stAttribs.dwAttribMask )
== (lpFlags->stAttribs.dwAttribMask & lpFlags->stAttribs.dwAttribVal ))
{
- ptrNextNode->ptrNext = malloc(sizeof(DIRFINDLISTNODE));
+ ptrNextNode->ptrNext = cmd_alloc(sizeof(DIRFINDLISTNODE));
if (ptrNextNode->ptrNext == NULL)
{
#ifdef _DEBUG
@@ -1799,14 +1798,14 @@
while (ptrStartNode)
{
ptrNextNode = ptrStartNode->ptrNext;
- free(ptrStartNode);
+ cmd_free(ptrStartNode);
ptrStartNode = ptrNextNode;
dwCount --;
}
return 1;
}
- /* If malloc fails we go to next file in hope it works,
+ /* If cmd_alloc fails we go to next file in hope it works,
without braking the linked list! */
if (ptrNextNode->ptrNext)
{
@@ -1850,7 +1849,7 @@
ptrNextNode->ptrNext = NULL;
/* Calculate and allocate space need for making an array of pointers */
- ptrFileArray = malloc(sizeof(LPWIN32_FIND_DATA) * dwCount);
+ ptrFileArray = cmd_alloc(sizeof(LPWIN32_FIND_DATA) * dwCount);
if (ptrFileArray == NULL)
{
#ifdef _DEBUG
@@ -1859,7 +1858,7 @@
while (ptrStartNode)
{
ptrNextNode = ptrStartNode->ptrNext;
- free(ptrStartNode);
+ cmd_free(ptrStartNode);
ptrStartNode = ptrNextNode;
dwCount --;
}
@@ -1887,7 +1886,7 @@
DirPrintFiles(ptrFileArray, dwCount, szFullPath, lpFlags);
/* Free array */
- free(ptrFileArray);
+ cmd_free(ptrFileArray);
if (CheckCtrlBreak(BREAK_INPUT))
return 1;
@@ -1933,7 +1932,7 @@
while (ptrStartNode)
{
ptrNextNode = ptrStartNode->ptrNext;
- free(ptrStartNode);
+ cmd_free(ptrStartNode);
ptrStartNode = ptrNextNode;
dwCount --;
}
Modified: trunk/reactos/base/shell/cmd/dirstack.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/dirstack.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/dirstack.c (original)
+++ trunk/reactos/base/shell/cmd/dirstack.c Wed Aug 1 14:17:13 2007
@@ -15,7 +15,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef FEATURE_DIRECTORY_STACK
@@ -39,7 +38,7 @@
nErrorLevel = 0;
- lpDir = (LPDIRENTRY)malloc (sizeof (DIRENTRY));
+ lpDir = (LPDIRENTRY)cmd_alloc (sizeof (DIRENTRY));
if (!lpDir)
{
error_out_of_memory ();
@@ -59,10 +58,10 @@
}
lpStackTop = lpDir;
- lpDir->pszPath = (LPTSTR)malloc ((_tcslen(pszPath)+1)*sizeof(TCHAR));
+ lpDir->pszPath = (LPTSTR)cmd_alloc ((_tcslen(pszPath)+1)*sizeof(TCHAR));
if (!lpDir->pszPath)
{
- free (lpDir);
+ cmd_free (lpDir);
error_out_of_memory ();
return -1;
}
@@ -92,8 +91,8 @@
else
lpStackBottom = NULL;
- free (lpDir->pszPath);
- free (lpDir);
+ cmd_free (lpDir->pszPath);
+ cmd_free (lpDir);
nStackDepth--;
}
Modified: trunk/reactos/base/shell/cmd/echo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/echo.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/echo.c (original)
+++ trunk/reactos/base/shell/cmd/echo.c Wed Aug 1 14:17:13 2007
@@ -27,7 +27,6 @@
*/
#include <precomp.h>
-#include "resource.h"
INT CommandEcho (LPTSTR cmd, LPTSTR param)
Modified: trunk/reactos/base/shell/cmd/error.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/error.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/error.c (original)
+++ trunk/reactos/base/shell/cmd/error.c Wed Aug 1 14:17:13 2007
@@ -21,7 +21,6 @@
*/
#include <precomp.h>
-#include "resource.h"
VOID ErrorMessage (DWORD dwErrorCode, LPTSTR szFormat, ...)
Modified: trunk/reactos/base/shell/cmd/filecomp.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/filecomp.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/filecomp.c (original)
+++ trunk/reactos/base/shell/cmd/filecomp.c Wed Aug 1 14:17:13 2007
@@ -21,7 +21,6 @@
*/
#include <precomp.h>
-#include "cmd.h"
#ifdef FEATURE_UNIX_FILENAME_COMPLETION
@@ -490,8 +489,8 @@
FileName * File2;
INT ret;
- File1 = malloc(sizeof(FileName));
- File2 = malloc(sizeof(FileName));
+ File1 = cmd_alloc(sizeof(FileName));
+ File2 = cmd_alloc(sizeof(FileName));
if(!File1 || !File2)
return 0;
@@ -501,8 +500,8 @@
/* ret = _tcsicmp(File1->Name, File2->Name); */
ret = lstrcmpi(File1->Name, File2->Name);
- free(File1);
- free(File2);
+ cmd_free(File1);
+ cmd_free(File2);
return ret;
}
@@ -628,7 +627,7 @@
}
/* Add the file to the list of files */
- FileList = realloc(FileList, ++FileListSize * sizeof(FileName));
+ FileList = cmd_realloc(FileList, ++FileListSize * sizeof(FileName));
if(FileList == NULL)
{
@@ -651,7 +650,7 @@
{
_tcscpy(strOut,szOrginal);
if(FileList != NULL)
- free(FileList);
+ cmd_free(FileList);
return;
}
@@ -741,7 +740,7 @@
EndLength = _tcslen(strOut);
DiffLength = EndLength - StartLength;
if(FileList != NULL)
- free(FileList);
+ cmd_free(FileList);
}
#endif
Modified: trunk/reactos/base/shell/cmd/for.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/for.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/for.c (original)
+++ trunk/reactos/base/shell/cmd/for.c Wed Aug 1 14:17:13 2007
@@ -31,7 +31,6 @@
*/
#include <precomp.h>
-#include "resource.h"
/*
@@ -126,7 +125,7 @@
}
/* OK all is correct, build a bcontext.... */
- lpNew = (LPBATCH_CONTEXT)malloc (sizeof (BATCH_CONTEXT));
+ lpNew = (LPBATCH_CONTEXT)cmd_alloc (sizeof (BATCH_CONTEXT));
lpNew->prev = bc;
bc = lpNew;
Modified: trunk/reactos/base/shell/cmd/free.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/free.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/free.c (original)
+++ trunk/reactos/base/shell/cmd/free.c Wed Aug 1 14:17:13 2007
@@ -12,7 +12,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_FREE
Modified: trunk/reactos/base/shell/cmd/goto.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/goto.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/goto.c (original)
+++ trunk/reactos/base/shell/cmd/goto.c Wed Aug 1 14:17:13 2007
@@ -27,7 +27,6 @@
*/
#include <precomp.h>
-#include "resource.h"
/*
Modified: trunk/reactos/base/shell/cmd/history.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/history.c?r…
==============================================================================
--- trunk/reactos/base/shell/cmd/history.c (original)
+++ trunk/reactos/base/shell/cmd/history.c Wed Aug 1 14:17:13 2007
@@ -139,8 +139,8 @@
{
size=0;
- Top = malloc(sizeof(HIST_ENTRY));
- Bottom = malloc(sizeof(HIST_ENTRY));
+ Top = cmd_alloc(sizeof(HIST_ENTRY));
+ Bottom = cmd_alloc(sizeof(HIST_ENTRY));
Top->prev = Bottom;
Top->next = NULL;
@@ -161,8 +161,8 @@
while (Bottom->next!=Top)
del(Bottom->next);
- free(Top);
- free(Bottom);
+ cmd_free(Top);
+ cmd_free(Bottom);
}
@@ -204,13 +204,13 @@
/*free string's mem*/
if (item->string)
- free(item->string);
+ cmd_free(item->string);
/*set links in prev and next item*/
item->next->prev=item->prev;
item->prev->next=item->next;
- free(item);
+ cmd_free(item);
size--;
}
@@ -233,8 +233,8 @@
return;
/*allocte entry and string*/
- tmp=malloc(sizeof(HIST_ENTRY));
- tmp->string=malloc((_tcslen(string)+1)*sizeof(TCHAR));
+ tmp=cmd_alloc(sizeof(HIST_ENTRY));
+ tmp->string=cmd_alloc((_tcslen(string)+1)*sizeof(TCHAR));
_tcscpy(tmp->string,string);
/*set links*/
@@ -280,7 +280,7 @@
/*fill bottom with string, it will become Bottom->next*/
- Bottom->string=malloc((_tcslen(string)+1)*sizeof(TCHAR));
+ Bottom->string=cmd_alloc((_tcslen(string)+1)*sizeof(TCHAR));
_tcscpy(Bottom->string,string);
/*save Bottom value*/
@@ -288,7 +288,7 @@
/*create new void Bottom*/
- Bottom=malloc(sizeof(HIST_ENTRY));
+ Bottom=cmd_alloc(sizeof(HIST_ENTRY));
Bottom->next=tmp;
Bottom->prev=NULL;
Bottom->string=NULL;
@@ -401,7 +401,7 @@
/*first time History is called allocate mem*/
if (!history)
{
- history = malloc (history_size * sizeof (TCHAR));
+ history = cmd_alloc (history_size * sizeof (TCHAR));
lines[0] = history;
history[0] = 0;
}
Modified: trunk/reactos/base/shell/cmd/if.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/if.c?rev=28…
==============================================================================
--- trunk/reactos/base/shell/cmd/if.c (original)
+++ trunk/reactos/base/shell/cmd/if.c Wed Aug 1 14:17:13 2007
@@ -31,7 +31,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#define X_EXEC 1
Modified: trunk/reactos/base/shell/cmd/internal.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/internal.c?…
==============================================================================
--- trunk/reactos/base/shell/cmd/internal.c (original)
+++ trunk/reactos/base/shell/cmd/internal.c Wed Aug 1 14:17:13 2007
@@ -138,7 +138,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_CHDIR
@@ -154,7 +153,7 @@
VOID FreeLastPath (VOID)
{
if (lpLastPath)
- free (lpLastPath);
+ cmd_free (lpLastPath);
}
/* help functions for getting current path from drive
@@ -766,11 +765,11 @@
/* If a param was send, display help of correspondent command */
if (_tcslen(param))
{
- LPTSTR NewCommand = malloc((_tcslen(param)+4)*sizeof(TCHAR));
+ LPTSTR NewCommand = cmd_alloc((_tcslen(param)+4)*sizeof(TCHAR));
_tcscpy(NewCommand, param);
_tcscat(NewCommand, _T(" /?"));
DoCommand(NewCommand);
- free(NewCommand);
+ cmd_free(NewCommand);
}
/* Else, display detailed commands list */
else
Modified: trunk/reactos/base/shell/cmd/label.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/label.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/label.c (original)
+++ trunk/reactos/base/shell/cmd/label.c Wed Aug 1 14:17:13 2007
@@ -18,7 +18,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_LABEL
Modified: trunk/reactos/base/shell/cmd/locale.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/locale.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/locale.c (original)
+++ trunk/reactos/base/shell/cmd/locale.c Wed Aug 1 14:17:13 2007
@@ -12,7 +12,6 @@
*/
#include <precomp.h>
-#include "resource.h"
TCHAR cDateSeparator;
Modified: trunk/reactos/base/shell/cmd/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/main.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/main.c (original)
+++ trunk/reactos/base/shell/cmd/main.c Wed Aug 1 14:17:13 2007
@@ -1,5 +1,4 @@
#include <precomp.h>
-#include "resource.h"
#ifdef _UNICODE
extern int _main (void);
Modified: trunk/reactos/base/shell/cmd/memory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/memory.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/memory.c (original)
+++ trunk/reactos/base/shell/cmd/memory.c Wed Aug 1 14:17:13 2007
@@ -12,7 +12,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_MEMORY
Modified: trunk/reactos/base/shell/cmd/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/misc.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/misc.c (original)
+++ trunk/reactos/base/shell/cmd/misc.c Wed Aug 1 14:17:13 2007
@@ -33,7 +33,6 @@
*/
#include <precomp.h>
-#include "resource.h"
/*
@@ -200,7 +199,7 @@
LPTSTR q;
LPTSTR *oldarg;
- q = malloc ((_tcslen(entry) + 1) * sizeof (TCHAR));
+ q = cmd_alloc ((_tcslen(entry) + 1) * sizeof (TCHAR));
if (NULL == q)
{
return FALSE;
@@ -208,7 +207,7 @@
_tcscpy (q, entry);
oldarg = *arg;
- *arg = realloc (oldarg, (*ac + 2) * sizeof (LPTSTR));
+ *arg = cmd_realloc (oldarg, (*ac + 2) * sizeof (LPTSTR));
if (NULL == *arg)
{
*arg = oldarg;
@@ -233,7 +232,7 @@
pathend = _tcsrchr (pattern, _T('\\'));
if (NULL != pathend)
{
- dirpart = malloc((pathend - pattern + 2) * sizeof(TCHAR));
+ dirpart = cmd_alloc((pathend - pattern + 2) * sizeof(TCHAR));
if (NULL == dirpart)
{
return FALSE;
@@ -252,7 +251,7 @@
{
if (NULL != dirpart)
{
- fullname = malloc((_tcslen(dirpart) + _tcslen(FindData.cFileName) + 1) *
sizeof(TCHAR));
+ fullname = cmd_alloc((_tcslen(dirpart) + _tcslen(FindData.cFileName) + 1) *
sizeof(TCHAR));
if (NULL == fullname)
{
ok = FALSE;
@@ -261,7 +260,7 @@
{
_tcscat (_tcscpy (fullname, dirpart), FindData.cFileName);
ok = add_entry(ac, arg, fullname);
- free (fullname);
+ cmd_free (fullname);
}
}
else
@@ -278,7 +277,7 @@
if (NULL != dirpart)
{
- free (dirpart);
+ cmd_free (dirpart);
}
return ok;
@@ -298,7 +297,7 @@
INT len;
BOOL bQuoted = FALSE;
- arg = malloc (sizeof (LPTSTR));
+ arg = cmd_alloc (sizeof (LPTSTR));
if (!arg)
return NULL;
*arg = NULL;
@@ -338,7 +337,7 @@
/* a word was found */
if (s != start)
{
- q = malloc (((len = s - start) + 1) * sizeof (TCHAR));
+ q = cmd_alloc (((len = s - start) + 1) * sizeof (TCHAR));
if (!q)
{
return NULL;
@@ -350,7 +349,7 @@
{
if (! expand(&ac, &arg, q))
{
- free (q);
+ cmd_free (q);
freep (arg);
return NULL;
}
@@ -359,12 +358,12 @@
{
if (! add_entry(&ac, &arg, q))
{
- free (q);
+ cmd_free (q);
freep (arg);
return NULL;
}
}
- free (q);
+ cmd_free (q);
}
/* adjust string pointer if quoted (") */
@@ -400,9 +399,9 @@
q = p;
while (*q)
- free(*q++);
-
- free(p);
+ cmd_free(*q++);
+
+ cmd_free(p);
}
@@ -457,7 +456,7 @@
DWORD dwRead;
INT len;
#ifdef _UNICODE
- lpString = malloc(nBufferLength);
+ lpString = cmd_alloc(nBufferLength);
#else
lpString = lpBuffer;
#endif
@@ -479,7 +478,7 @@
lpString[len++] = _T('\0');
#ifdef _UNICODE
MultiByteToWideChar(CP_ACP, 0, lpString, len, lpBuffer, len);
- free(lpString);
+ cmd_free(lpString);
#endif
return TRUE;
}
Modified: trunk/reactos/base/shell/cmd/move.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/move.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/move.c (original)
+++ trunk/reactos/base/shell/cmd/move.c Wed Aug 1 14:17:13 2007
@@ -30,7 +30,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_MOVE
Modified: trunk/reactos/base/shell/cmd/msgbox.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/msgbox.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/msgbox.c (original)
+++ trunk/reactos/base/shell/cmd/msgbox.c Wed Aug 1 14:17:13 2007
@@ -11,7 +11,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_MSGBOX
Modified: trunk/reactos/base/shell/cmd/path.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/path.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/path.c (original)
+++ trunk/reactos/base/shell/cmd/path.c Wed Aug 1 14:17:13 2007
@@ -26,7 +26,6 @@
* Remove all hardcode string to En.rc
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_PATH
@@ -52,7 +51,7 @@
LPTSTR pszBuffer;
TCHAR szMsg[RC_STRING_MAX_SIZE];
- pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
+ pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer == 0)
{
@@ -62,12 +61,12 @@
}
else if (dwBuffer > ENV_BUFFER_SIZE)
{
- pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
+ pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
}
ConOutPrintf (_T("PATH=%s\n"), pszBuffer);
- free (pszBuffer);
+ cmd_free (pszBuffer);
return 0;
}
Modified: trunk/reactos/base/shell/cmd/pause.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/pause.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/pause.c (original)
+++ trunk/reactos/base/shell/cmd/pause.c Wed Aug 1 14:17:13 2007
@@ -18,7 +18,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_PAUSE
Modified: trunk/reactos/base/shell/cmd/precomp.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/precomp.h?r…
==============================================================================
--- trunk/reactos/base/shell/cmd/precomp.h (original)
+++ trunk/reactos/base/shell/cmd/precomp.h Wed Aug 1 14:17:13 2007
@@ -5,6 +5,7 @@
#endif//_MSC_VER
#include <stdlib.h>
+#include <malloc.h>
#define WIN32_NO_STATUS
#include <windows.h>
#include <winnt.h>
@@ -23,7 +24,11 @@
#define NTOS_MODE_USER
#include <ndk/ntndk.h>
+#include "resource.h"
+
#include "cmd.h"
#include "config.h"
#include "batch.h"
+#include <reactos/resource.h>
+
Modified: trunk/reactos/base/shell/cmd/prompt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/prompt.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/prompt.c (original)
+++ trunk/reactos/base/shell/cmd/prompt.c Wed Aug 1 14:17:13 2007
@@ -47,7 +47,6 @@
* Remove all hardcode string to En.rc
*/
#include <precomp.h>
-#include "resource.h"
/*
* print the command-line prompt
Modified: trunk/reactos/base/shell/cmd/ren.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/ren.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/ren.c (original)
+++ trunk/reactos/base/shell/cmd/ren.c Wed Aug 1 14:17:13 2007
@@ -21,7 +21,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_RENAME
Modified: trunk/reactos/base/shell/cmd/screen.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/screen.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/screen.c (original)
+++ trunk/reactos/base/shell/cmd/screen.c Wed Aug 1 14:17:13 2007
@@ -12,7 +12,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_SCREEN
Modified: trunk/reactos/base/shell/cmd/set.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/set.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/set.c (original)
+++ trunk/reactos/base/shell/cmd/set.c Wed Aug 1 14:17:13 2007
@@ -5,7 +5,7 @@
* History:
*
* 06/14/97 (Tim Norman)
- * changed static var in set() to a malloc'd space to pass to putenv.
+ * changed static var in set() to a cmd_alloc'd space to pass to putenv.
* need to find a better way to do this, since it seems it is wasting
* memory when variables are redefined.
*
@@ -35,9 +35,6 @@
*/
#include <precomp.h>
-#include <malloc.h>
-#include <stdio.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_SET
@@ -141,7 +138,7 @@
LPTSTR pszBuffer;
DWORD dwBuffer;
- pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
+ pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
dwBuffer = GetEnvironmentVariable (param, pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer == 0)
{
@@ -151,12 +148,12 @@
}
else if (dwBuffer > ENV_BUFFER_SIZE)
{
- pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
+ pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
GetEnvironmentVariable (param, pszBuffer, dwBuffer);
}
ConOutPrintf (_T("%s\n"), pszBuffer);
- free (pszBuffer);
+ cmd_free (pszBuffer);
return 0;
}
Modified: trunk/reactos/base/shell/cmd/shift.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/shift.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/shift.c (original)
+++ trunk/reactos/base/shell/cmd/shift.c Wed Aug 1 14:17:13 2007
@@ -24,7 +24,6 @@
*/
#include <precomp.h>
-#include "resource.h"
/*
Modified: trunk/reactos/base/shell/cmd/start.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/start.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/start.c (original)
+++ trunk/reactos/base/shell/cmd/start.c Wed Aug 1 14:17:13 2007
@@ -12,7 +12,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_START
@@ -90,7 +89,7 @@
freep (arg);
/* get comspec */
- comspec = malloc ( MAX_PATH * sizeof(TCHAR));
+ comspec = cmd_alloc ( MAX_PATH * sizeof(TCHAR));
if (comspec == NULL)
{
error_out_of_memory();
@@ -109,7 +108,7 @@
{
if (size > MAX_PATH)
{
- comspec = realloc(comspec,size * sizeof(TCHAR) );
+ comspec = cmd_realloc(comspec,size * sizeof(TCHAR) );
if (comspec==NULL)
{
return 1;
@@ -127,21 +126,21 @@
_tcscat(RestWithoutArgs,_T("\""));
}
- rest = malloc ( (_tcslen(RestWithoutArgs) + 1) * sizeof(TCHAR));
+ rest = cmd_alloc ( (_tcslen(RestWithoutArgs) + 1) * sizeof(TCHAR));
if (rest == NULL)
{
if(comspec != NULL)
- free(comspec);
+ cmd_free(comspec);
error_out_of_memory();
return 1;
}
- param =malloc ( (_tcslen(RestWithoutArgs) + 1) * sizeof(TCHAR));
+ param =cmd_alloc ( (_tcslen(RestWithoutArgs) + 1) * sizeof(TCHAR));
if (rest == NULL)
{
if(comspec != NULL)
- free(comspec);
- free(rest);
+ cmd_free(comspec);
+ cmd_free(rest);
error_out_of_memory();
return 1;
}
@@ -210,12 +209,12 @@
ConErrResPuts (STRING_FREE_ERROR1);
if (rest != NULL)
- free(rest);
+ cmd_free(rest);
if (param != NULL)
- free(param);
+ cmd_free(param);
if (comspec != NULL)
- free(comspec);
+ cmd_free(comspec);
return 0;
}
@@ -226,13 +225,13 @@
error_bad_command ();
if (rest != NULL)
- free(rest);
+ cmd_free(rest);
if (param != NULL)
- free(param);
+ cmd_free(param);
if (comspec != NULL)
- free(comspec);
+ cmd_free(comspec);
return 1;
}
@@ -314,13 +313,13 @@
if (rest != NULL)
- free(rest);
+ cmd_free(rest);
if (param != NULL)
- free(param);
+ cmd_free(param);
if (comspec != NULL)
- free(comspec);
+ cmd_free(comspec);
return 0;
}
Modified: trunk/reactos/base/shell/cmd/time.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/time.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/time.c (original)
+++ trunk/reactos/base/shell/cmd/time.c Wed Aug 1 14:17:13 2007
@@ -25,7 +25,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_TIME
Modified: trunk/reactos/base/shell/cmd/timer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/timer.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/timer.c (original)
+++ trunk/reactos/base/shell/cmd/timer.c Wed Aug 1 14:17:13 2007
@@ -8,7 +8,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_TIMER
Modified: trunk/reactos/base/shell/cmd/title.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/title.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/title.c (original)
+++ trunk/reactos/base/shell/cmd/title.c Wed Aug 1 14:17:13 2007
@@ -10,7 +10,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_TITLE
Modified: trunk/reactos/base/shell/cmd/type.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/type.c?rev=…
==============================================================================
--- trunk/reactos/base/shell/cmd/type.c (original)
+++ trunk/reactos/base/shell/cmd/type.c Wed Aug 1 14:17:13 2007
@@ -27,7 +27,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_TYPE
Modified: trunk/reactos/base/shell/cmd/ver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/ver.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/ver.c (original)
+++ trunk/reactos/base/shell/cmd/ver.c Wed Aug 1 14:17:13 2007
@@ -22,8 +22,6 @@
*/
#include <precomp.h>
-#include "resource.h"
-#include <reactos/resource.h>
VOID ShortVersion (VOID)
Modified: trunk/reactos/base/shell/cmd/verify.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/verify.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/verify.c (original)
+++ trunk/reactos/base/shell/cmd/verify.c Wed Aug 1 14:17:13 2007
@@ -19,7 +19,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_VERIFY
Modified: trunk/reactos/base/shell/cmd/vol.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/vol.c?rev=2…
==============================================================================
--- trunk/reactos/base/shell/cmd/vol.c (original)
+++ trunk/reactos/base/shell/cmd/vol.c Wed Aug 1 14:17:13 2007
@@ -21,7 +21,6 @@
*/
#include <precomp.h>
-#include "resource.h"
#ifdef INCLUDE_CMD_VOL
Modified: trunk/reactos/base/shell/cmd/where.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/where.c?rev…
==============================================================================
--- trunk/reactos/base/shell/cmd/where.c (original)
+++ trunk/reactos/base/shell/cmd/where.c Wed Aug 1 14:17:13 2007
@@ -151,11 +151,11 @@
/* load environment varable PATH into buffer */
- pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
+ pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
dwBuffer = GetEnvironmentVariable (_T("PATH"), pszBuffer, ENV_BUFFER_SIZE);
if (dwBuffer > ENV_BUFFER_SIZE)
{
- pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
+ pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
GetEnvironmentVariable (_T("PATH"), pszBuffer, dwBuffer);
}
@@ -194,12 +194,12 @@
#ifdef _DEBUG
DebugPrintf (_T("Found: \'%s\'\n"), szPathBuffer);
#endif
- free (pszBuffer);
+ cmd_free (pszBuffer);
_tcscpy (pFullName, szPathBuffer);
return TRUE;
}
}
- free (pszBuffer);
+ cmd_free (pszBuffer);
return FALSE;
}
@@ -216,11 +216,11 @@
DebugPrintf (_T("SearchForExecutable: \'%s\'\n"), pFileName);
#endif
/* load environment varable PATHEXT */
- pszBuffer = (LPTSTR)malloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
+ pszBuffer = (LPTSTR)cmd_alloc (ENV_BUFFER_SIZE * sizeof(TCHAR));
dwBuffer = GetEnvironmentVariable (_T("PATHEXT"), pszBuffer,
ENV_BUFFER_SIZE);
if (dwBuffer > ENV_BUFFER_SIZE)
{
- pszBuffer = (LPTSTR)realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
+ pszBuffer = (LPTSTR)cmd_realloc (pszBuffer, dwBuffer * sizeof (TCHAR));
GetEnvironmentVariable (_T("PATHEXT"), pszBuffer, dwBuffer);
}
else if (0 == dwBuffer)
@@ -244,13 +244,13 @@
{
if (0 == _tcsicmp(pCh, pExt))
{
- free(pszBuffer);
- free(pszBuffer2);
+ cmd_free(pszBuffer);
+ cmd_free(pszBuffer2);
return SearchForExecutableSingle(pFileName, pFullName, NULL);
}
pCh = _tcstok(NULL, _T(";"));
}
- free(pszBuffer2);
+ cmd_free(pszBuffer2);
}
}
@@ -259,13 +259,13 @@
{
if (SearchForExecutableSingle(pFileName, pFullName, pCh))
{
- free(pszBuffer);
+ cmd_free(pszBuffer);
return TRUE;
}
pCh = _tcstok(NULL, _T(";"));
}
- free(pszBuffer);
+ cmd_free(pszBuffer);
return FALSE;
}
Modified: trunk/reactos/base/shell/cmd/window.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/shell/cmd/window.c?re…
==============================================================================
--- trunk/reactos/base/shell/cmd/window.c (original)
+++ trunk/reactos/base/shell/cmd/window.c Wed Aug 1 14:17:13 2007
@@ -17,7 +17,6 @@
#include <precomp.h>
-#include "resource.h"
#if ( defined(INCLUDE_CMD_WINDOW) || defined(INCLUDE_CMD_ACTIVATE) )