Author: pschweitzer
Date: Mon Feb 7 23:23:33 2011
New Revision: 50616
URL:
http://svn.reactos.org/svn/reactos?rev=50616&view=rev
Log:
[RTL]
Minor code changes to RTL (one would call them "optimisation"). Added some
missing paged code.
Plus added useful asserts (used to catch r50615 bug!)
Modified:
trunk/reactos/lib/rtl/nls.c
trunk/reactos/lib/rtl/unicode.c
Modified: trunk/reactos/lib/rtl/nls.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/nls.c?rev=50616&am…
==============================================================================
--- trunk/reactos/lib/rtl/nls.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/nls.c [iso-8859-1] Mon Feb 7 23:23:33 2011
@@ -235,6 +235,8 @@
ULONG Size = 0;
ULONG i;
+ PAGED_CODE_RTL();
+
if (NlsMbCodePageTag == FALSE)
{
/* single-byte code page */
@@ -299,6 +301,8 @@
ULONG MbSize)
{
ULONG Length = 0;
+
+ PAGED_CODE_RTL();
if (!NlsMbCodePageTag)
{
@@ -503,6 +507,8 @@
{
ULONG Size = 0;
ULONG i;
+
+ PAGED_CODE_RTL();
if (NlsMbCodePageTag == FALSE)
{
Modified: trunk/reactos/lib/rtl/unicode.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/unicode.c?rev=5061…
==============================================================================
--- trunk/reactos/lib/rtl/unicode.c [iso-8859-1] (original)
+++ trunk/reactos/lib/rtl/unicode.c [iso-8859-1] Mon Feb 7 23:23:33 2011
@@ -76,7 +76,14 @@
PAGED_CODE_RTL();
- Length = RtlAnsiStringToUnicodeSize(AnsiSource);
+ if (NlsMbCodePageTag == FALSE)
+ {
+ Length = AnsiSource->Length * 2 + sizeof(WCHAR);
+ }
+ else
+ {
+ Length = RtlxAnsiStringToUnicodeSize(AnsiSource);
+ }
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
UniDest->Length = (USHORT)Length - sizeof(WCHAR);
@@ -90,6 +97,9 @@
{
return STATUS_BUFFER_OVERFLOW;
}
+
+ /* UniDest->MaximumLength must be even due to sizeof(WCHAR) being 2 */
+ ASSERT(!(UniDest->MaximumLength & 1) && UniDest->Length <=
UniDest->MaximumLength);
Status = RtlMultiByteToUnicodeN(UniDest->Buffer,
UniDest->Length,
@@ -122,6 +132,8 @@
RtlxAnsiStringToUnicodeSize(IN PCANSI_STRING AnsiString)
{
ULONG Size;
+
+ PAGED_CODE_RTL();
/* Convert from Mb String to Unicode Size */
RtlMultiByteToUnicodeSize(&Size,
@@ -963,7 +975,16 @@
PAGED_CODE_RTL();
- Length = RtlUnicodeStringToAnsiSize(UniSource);
+ ASSERT(!(UniSource->Length & 1));
+
+ if (NlsMbCodePageTag == FALSE)
+ {
+ Length = (UniSource->Length + sizeof(WCHAR)) / sizeof(WCHAR);
+ }
+ else
+ {
+ Length = RtlxUnicodeStringToAnsiSize(UniSource);
+ }
if (Length > MAXUSHORT) return STATUS_INVALID_PARAMETER_2;
AnsiDest->Length = (USHORT)Length - sizeof(CHAR);
@@ -1953,6 +1974,10 @@
{
ULONG Size;
+ PAGED_CODE_RTL();
+
+ ASSERT(!(UnicodeString->Length & 1));
+
/* Convert the Unicode String to Mb Size */
RtlUnicodeToMultiByteSize(&Size,
UnicodeString->Buffer,