diff options
author | John Ankarström <john@ankarstrom.se> | 2022-08-06 16:59:56 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-08-06 16:59:56 +0200 |
commit | c92d449f7a055769f518a809487f97d8272c4e9d (patch) | |
tree | 9fd704fe7c5601c42e86724b7b7c07c2fad6b38b /c/wcharptr.cpp | |
parent | 86a0cec08f11de875d25012e5b251a91739ce06c (diff) | |
download | EpisodeBrowser-c92d449f7a055769f518a809487f97d8272c4e9d.tar.gz |
Update Hungarian notation for buffer sizes.
For string lengths EXCLUDING NUL, I use len, whereas cb and cch are
used for string lengths INCLUDING NUL.
cb = byte count = sizeof(a) = narrow string length
cch = character count = sizeof(a)/sizeof(*a) = string length
cb and cch are equivalent for narrow strings. I prefer cch.
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; } |