diff options
author | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-07 18:45:26 +0000 |
---|---|---|
committer | beng@google.com <beng@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-09-07 18:45:26 +0000 |
commit | 62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4 (patch) | |
tree | cc4022c66148374716e214722ddeee8ea3d0e6c6 /chrome/common/win_util.cc | |
parent | f37e85112f6e1ce670bc50963f79b392c6af30bb (diff) | |
download | chromium_src-62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4.zip chromium_src-62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4.tar.gz chromium_src-62eb8e3e7347765f88e28c2cbc7e7b9223ca13a4.tar.bz2 |
Don't reinvent the wheel - base::wclscpy does this work in one line of code.
Review URL: http://codereview.chromium.org/1807
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1828 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/win_util.cc')
-rw-r--r-- | chrome/common/win_util.cc | 7 |
1 files changed, 1 insertions, 6 deletions
diff --git a/chrome/common/win_util.cc b/chrome/common/win_util.cc index 36e1f86..8bc7651 100644 --- a/chrome/common/win_util.cc +++ b/chrome/common/win_util.cc @@ -397,13 +397,8 @@ bool SaveFileAsWithFilter(HWND owner, // will be written into by Windows when the user is done with the dialog box. std::wstring file_part = file_util::GetFilenameFromPath(suggested_name); - // This will clamp the number of characters copied from the supplied path - // to the value of MAX_PATH. - size_t name_size = std::min(file_part.length() + 1, - static_cast<size_t>(MAX_PATH)); wchar_t file_name[MAX_PATH]; - memcpy(file_name, file_part.c_str(), name_size * sizeof(wchar_t)); - file_name[MAX_PATH - 1] = '\0'; + base::wcslcpy(file_name, file_part.c_str(), arraysize(file_name)); OPENFILENAME save_as; // We must do this otherwise the ofn's FlagsEx may be initialized to random |