diff options
Diffstat (limited to 'c/wcharptr.cpp')
-rw-r--r-- | c/wcharptr.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/c/wcharptr.cpp b/c/wcharptr.cpp index d1332d5..f36c620 100644 --- a/c/wcharptr.cpp +++ b/c/wcharptr.cpp @@ -6,10 +6,10 @@ WcharPtr WcharPtr::FromNarrow(const char* const src, const int cp) { - int cbMultiByte = strlen(src)+1; - int cchWideChar = MultiByteToWideChar(cp, 0, src, cbMultiByte, nullptr, 0); - wchar_t* dst = new wchar_t[cchWideChar]; - if (!MultiByteToWideChar(cp, 0, src, cbMultiByte, dst, cchWideChar)) { + int cchNarrow = strlen(src)+1; + int cchWide = MultiByteToWideChar(cp, 0, src, cchNarrow, nullptr, 0); + wchar_t* dst = new wchar_t[cchWide]; + if (!MultiByteToWideChar(cp, 0, src, cchNarrow, dst, cchWide)) { delete dst; throw Win32Error(); } @@ -18,9 +18,9 @@ WcharPtr WcharPtr::FromNarrow(const char* const src, const int cp) WcharPtr WcharPtr::Copy(const wchar_t* const src) { - const int cb = wcslen(src)+1; - wchar_t* dst = new wchar_t[cb]; - memcpy(dst, src, cb*sizeof(wchar_t)); + const int cch = wcslen(src)+1; + wchar_t* dst = new wchar_t[cch]; + memcpy(dst, src, cch*sizeof(wchar_t)); return dst; } |