Author: hbelusca
Date: Thu May 8 22:24:38 2014
New Revision: 63198
URL:
http://svn.reactos.org/svn/reactos?rev=63198&view=rev
Log:
[KERNEL32]
No need to precalculate the string lengths before calling the helper functions. They can
do it instead.
Modified:
branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c
branches/condrv_restructure/dll/win32/kernel32/client/console/console.c
branches/condrv_restructure/dll/win32/kernel32/client/console/history.c
Modified: branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/win32/ke…
==============================================================================
--- branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/dll/win32/kernel32/client/console/alias.c [iso-8859-1] Thu
May 8 22:24:38 2014
@@ -388,11 +388,13 @@
static DWORD
-IntGetConsoleAliasesLength(LPVOID lpExeName, DWORD dwNumChars, BOOLEAN bUnicode)
+IntGetConsoleAliasesLength(LPVOID lpExeName, BOOLEAN bUnicode)
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETALLALIASESLENGTH GetAllAliasesLengthRequest =
&ApiMessage.Data.GetAllAliasesLengthRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
+
+ DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) :
0);
if (lpExeName == NULL || dwNumChars == 0)
{
@@ -442,13 +444,7 @@
WINAPI
GetConsoleAliasesLengthW(LPWSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- return IntGetConsoleAliasesLength(lpExeName, wcslen(lpExeName), TRUE);
+ return IntGetConsoleAliasesLength(lpExeName, TRUE);
}
@@ -459,13 +455,7 @@
WINAPI
GetConsoleAliasesLengthA(LPSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- return IntGetConsoleAliasesLength(lpExeName, strlen(lpExeName), FALSE);
+ return IntGetConsoleAliasesLength(lpExeName, FALSE);
}
Modified: branches/condrv_restructure/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/win32/ke…
==============================================================================
--- branches/condrv_restructure/dll/win32/kernel32/client/console/console.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/dll/win32/kernel32/client/console/console.c [iso-8859-1]
Thu May 8 22:24:38 2014
@@ -1867,11 +1867,13 @@
static BOOL
-IntSetConsoleTitle(CONST VOID *lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
+IntSetConsoleTitle(CONST VOID *lpConsoleTitle, BOOLEAN bUnicode)
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
+
+ DWORD dwNumChars = (lpConsoleTitle ? (bUnicode ? wcslen(lpConsoleTitle) :
strlen(lpConsoleTitle)) : 0);
TitleRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) :
sizeof(CHAR));
@@ -1915,7 +1917,7 @@
WINAPI
SetConsoleTitleW(LPCWSTR lpConsoleTitle)
{
- return IntSetConsoleTitle(lpConsoleTitle, wcslen(lpConsoleTitle), TRUE);
+ return IntSetConsoleTitle(lpConsoleTitle, TRUE);
}
@@ -1928,7 +1930,7 @@
WINAPI
SetConsoleTitleA(LPCSTR lpConsoleTitle)
{
- return IntSetConsoleTitle(lpConsoleTitle, strlen(lpConsoleTitle), FALSE);
+ return IntSetConsoleTitle(lpConsoleTitle, FALSE);
}
Modified: branches/condrv_restructure/dll/win32/kernel32/client/console/history.c
URL:
http://svn.reactos.org/svn/reactos/branches/condrv_restructure/dll/win32/ke…
==============================================================================
--- branches/condrv_restructure/dll/win32/kernel32/client/console/history.c [iso-8859-1]
(original)
+++ branches/condrv_restructure/dll/win32/kernel32/client/console/history.c [iso-8859-1]
Thu May 8 22:24:38 2014
@@ -52,11 +52,13 @@
#endif
static VOID
-IntExpungeConsoleCommandHistory(LPCVOID lpExeName, DWORD dwNumChars, BOOLEAN bUnicode)
+IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOLEAN bUnicode)
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_EXPUNGECOMMANDHISTORY ExpungeCommandHistoryRequest =
&ApiMessage.Data.ExpungeCommandHistoryRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
+
+ DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) :
0);
if (lpExeName == NULL || dwNumChars == 0)
{
@@ -98,11 +100,13 @@
static DWORD
-IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, DWORD
dwNumChars, BOOLEAN bUnicode)
+IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, BOOLEAN
bUnicode)
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETCOMMANDHISTORY GetCommandHistoryRequest =
&ApiMessage.Data.GetCommandHistoryRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
+
+ DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) :
0);
if (lpExeName == NULL || dwNumChars == 0)
{
@@ -160,11 +164,13 @@
static DWORD
-IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, DWORD dwNumChars, BOOL bUnicode)
+IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode)
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETCOMMANDHISTORYLENGTH GetCommandHistoryLengthRequest =
&ApiMessage.Data.GetCommandHistoryLengthRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
+
+ DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) :
0);
if (lpExeName == NULL || dwNumChars == 0)
{
@@ -213,12 +219,13 @@
static BOOL
IntSetConsoleNumberOfCommands(DWORD dwNumCommands,
LPCVOID lpExeName,
- DWORD dwNumChars,
BOOLEAN bUnicode)
{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_SETHISTORYNUMBERCOMMANDS SetHistoryNumberCommandsRequest =
&ApiMessage.Data.SetHistoryNumberCommandsRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
+
+ DWORD dwNumChars = (lpExeName ? (bUnicode ? wcslen(lpExeName) : strlen(lpExeName)) :
0);
if (lpExeName == NULL || dwNumChars == 0)
{
@@ -274,13 +281,7 @@
WINAPI
ExpungeConsoleCommandHistoryW(LPCWSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return;
- }
-
- IntExpungeConsoleCommandHistory(lpExeName, wcslen(lpExeName), TRUE);
+ IntExpungeConsoleCommandHistory(lpExeName, TRUE);
}
@@ -291,13 +292,7 @@
WINAPI
ExpungeConsoleCommandHistoryA(LPCSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return;
- }
-
- IntExpungeConsoleCommandHistory(lpExeName, strlen(lpExeName), FALSE);
+ IntExpungeConsoleCommandHistory(lpExeName, FALSE);
}
@@ -310,13 +305,7 @@
DWORD cbHistory,
LPCWSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName,
wcslen(lpExeName), TRUE);
+ return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, TRUE);
}
@@ -329,13 +318,7 @@
DWORD cbHistory,
LPCSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName,
strlen(lpExeName), FALSE);
+ return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, FALSE);
}
@@ -346,13 +329,7 @@
WINAPI
GetConsoleCommandHistoryLengthW(LPCWSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- return IntGetConsoleCommandHistoryLength(lpExeName, wcslen(lpExeName), TRUE);
+ return IntGetConsoleCommandHistoryLength(lpExeName, TRUE);
}
@@ -363,13 +340,7 @@
WINAPI
GetConsoleCommandHistoryLengthA(LPCSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return 0;
- }
-
- return IntGetConsoleCommandHistoryLength(lpExeName, strlen(lpExeName), FALSE);
+ return IntGetConsoleCommandHistoryLength(lpExeName, FALSE);
}
@@ -381,13 +352,7 @@
SetConsoleNumberOfCommandsW(DWORD dwNumCommands,
LPCWSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, wcslen(lpExeName),
TRUE);
+ return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, TRUE);
}
@@ -399,13 +364,7 @@
SetConsoleNumberOfCommandsA(DWORD dwNumCommands,
LPCSTR lpExeName)
{
- if (lpExeName == NULL)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
- return FALSE;
- }
-
- return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, strlen(lpExeName),
FALSE);
+ return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, FALSE);
}