Skip to content

Commit

Permalink
Fix compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
huoyaoyuan committed Dec 19, 2023
1 parent 90d51cc commit c756156
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/coreclr/inc/corhlprpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ class CQuickMemoryBase
size_t sourceLen = strlen(utf8str);
size_t destLen = minipal_get_length_utf8_to_utf16(utf8str, sourceLen, 0);

LPWSTR buffer = (LPWSTR) AllocThrows((length + 1) * sizeof(WCHAR));
CHAR16_T* buffer = (CHAR16_T*) AllocThrows((destLen + 1) * sizeof(CHAR16_T));

if (!minipal_convert_utf8_to_utf16(utf8str, sourceLen, buffer, destLen, 0))
{
Expand All @@ -243,11 +243,11 @@ class CQuickMemoryBase
void ConvertUnicode_Utf8(const WCHAR * pString)
{
size_t sourceLen = u16_strlen(pString);
size_t destLen = minipal_get_length_utf16_to_utf8(pString, sourceLen, 0);
size_t destLen = minipal_get_length_utf16_to_utf8((const CHAR16_T*)pString, sourceLen, 0);

LPSTR buffer = (LPSTR) AllocThrows((length + 1) * sizeof(char));
LPSTR buffer = (LPSTR) AllocThrows((destLen + 1) * sizeof(char));

if (!minipal_convert_utf16_to_utf8(pString, sourceLen, buffer, destLen, 0))
if (!minipal_convert_utf16_to_utf8((const CHAR16_T*)pString, sourceLen, buffer, destLen, 0))
{
ThrowHR(COR_E_INSUFFICIENTMEMORY);
}
Expand Down
8 changes: 4 additions & 4 deletions src/coreclr/utilcode/sstring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -865,16 +865,16 @@ COUNT_T SString::ConvertToUTF8(SString &s) const
UNREACHABLE();
}

size_t length = minipal_get_length_utf16_to_utf8(GetRawUnicode(), GetCount(), MINIPAL_MB_NO_REPLACE_INVALID_CHARS);
size_t length = minipal_get_length_utf16_to_utf8((CHAR16_T*)GetRawUnicode(), GetCount(), MINIPAL_MB_NO_REPLACE_INVALID_CHARS);

if (length <= COUNT_T_MAX)
{
s.Resize(length, REPRESENTATION_UTF8);
s.Resize((COUNT_T)length, REPRESENTATION_UTF8);

//we optimize the empty string by replacing it with null for SString above in Resize
if (length > 0)
{
if (!minipal_convert_utf16_to_utf8(GetRawUnicode(), GetCount(), s.GetRawUTF8(), length, MINIPAL_MB_NO_REPLACE_INVALID_CHARS))
if (!minipal_convert_utf16_to_utf8((CHAR16_T*)GetRawUnicode(), GetCount(), s.GetRawUTF8(), length, MINIPAL_MB_NO_REPLACE_INVALID_CHARS))
{
ThrowHR(COR_E_INSUFFICIENTMEMORY);
}
Expand All @@ -885,7 +885,7 @@ COUNT_T SString::ConvertToUTF8(SString &s) const
ThrowHR(COR_E_OVERFLOW);
}

RETURN length + 1;
RETURN (COUNT_T)length + 1;
}

//-----------------------------------------------------------------------------
Expand Down

0 comments on commit c756156

Please sign in to comment.