diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2018-09-07 16:09:50 +0200 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2018-09-07 22:04:50 +0200 |
commit | b18747fcee1ba8744e5cd63791dc9f3eb6848a56 (patch) | |
tree | 51d0216e5f58822e820861499605e145e563dff5 | |
parent | 694a6389e84d5b416cde6dde2d5eaa589a0a6493 (diff) |
Fix some std::unique_ptr array allocs
Found by reviewing the output of and the code around
git grep -n "unique_ptr.*new.*\[.*\]" | grep -v "\[\]"
The onlineupdater code needs a little bit more attention.
Change-Id: I8b70c7da7db60af52bfac12314a21602ede8bfc0
Reviewed-on: https://gerrit.libreoffice.org/60162
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
-rw-r--r-- | dtrans/source/win32/misc/ImplHelper.cxx | 2 | ||||
-rw-r--r-- | onlineupdate/source/update/updater/updater.cxx | 32 | ||||
-rw-r--r-- | vcl/opengl/win/WinDeviceInfo.cxx | 2 | ||||
-rw-r--r-- | vcl/win/app/salinst.cxx | 2 | ||||
-rw-r--r-- | vcl/win/window/salframe.cxx | 4 |
5 files changed, 21 insertions, 21 deletions
diff --git a/dtrans/source/win32/misc/ImplHelper.cxx b/dtrans/source/win32/misc/ImplHelper.cxx index 4b98b4850006..f933701ce961 100644 --- a/dtrans/source/win32/misc/ImplHelper.cxx +++ b/dtrans/source/win32/misc/ImplHelper.cxx @@ -95,7 +95,7 @@ OUString getWinCPFromLocaleId( LCID lcid, LCTYPE lctype ) if ( nResult ) { - std::unique_ptr<wchar_t> buff( new wchar_t[nResult] ); + std::unique_ptr<wchar_t[]> buff( new wchar_t[nResult] ); // Now get the actual data nResult = GetLocaleInfoW( lcid, lctype, buff.get(), nResult ); diff --git a/onlineupdate/source/update/updater/updater.cxx b/onlineupdate/source/update/updater/updater.cxx index 1782804eff15..a05fd075bd3a 100644 --- a/onlineupdate/source/update/updater/updater.cxx +++ b/onlineupdate/source/update/updater/updater.cxx @@ -1119,8 +1119,8 @@ public: void Finish(int status); private: - std::unique_ptr<const NS_tchar> mFile; - std::unique_ptr<NS_tchar> mRelPath; + std::unique_ptr<const NS_tchar[]> mFile; + std::unique_ptr<NS_tchar[]> mRelPath; int mSkip; }; @@ -1247,8 +1247,8 @@ public: virtual void Finish(int status); private: - std::unique_ptr<NS_tchar> mDir; - std::unique_ptr<NS_tchar> mRelPath; + std::unique_ptr<NS_tchar[]> mDir; + std::unique_ptr<NS_tchar[]> mRelPath; int mSkip; }; @@ -1260,6 +1260,7 @@ RemoveDir::Parse(NS_tchar *line) NS_tchar* validPath = get_valid_path(&line, true); if (!validPath) return PARSE_ERROR; + mRelPath.reset(new NS_tchar[MAXPATHLEN]); NS_tstrcpy(mRelPath.get(), validPath); @@ -1371,8 +1372,8 @@ public: virtual void Finish(int status); private: - std::unique_ptr<NS_tchar> mFile; - std::unique_ptr<NS_tchar> mRelPath; + std::unique_ptr<NS_tchar[]> mFile; + std::unique_ptr<NS_tchar[]> mRelPath; bool mAdded; ArchiveReader& mArchiveReader; }; @@ -1387,7 +1388,6 @@ AddFile::Parse(NS_tchar *line) return PARSE_ERROR; mRelPath.reset(new NS_tchar[MAXPATHLEN]); - NS_tstrcpy(mRelPath.get(), validPath); mFile.reset(get_full_path(validPath)); @@ -1799,7 +1799,7 @@ public: virtual void Finish(int status); protected: - std::unique_ptr<NS_tchar> mTestFile; + std::unique_ptr<NS_tchar[]> mTestFile; }; AddIfFile::AddIfFile(ArchiveReader& archiveReader): @@ -1866,7 +1866,7 @@ public: virtual void Finish(int status); protected: - std::unique_ptr<NS_tchar> mTestFile; + std::unique_ptr<NS_tchar[]> mTestFile; }; AddIfNotFile::AddIfNotFile(ArchiveReader& archiveReader): @@ -1933,7 +1933,7 @@ public: virtual void Finish(int status); private: - std::unique_ptr<NS_tchar> mTestFile; + std::unique_ptr<NS_tchar[]> mTestFile; }; PatchIfFile::PatchIfFile(ArchiveReader& archiveReader): @@ -2323,7 +2323,7 @@ CopyInstallDirToDestDir() #endif copy_recursive_skiplist<SKIPLIST_COUNT> skiplist; - std::unique_ptr<NS_tchar> pUserProfile(new NS_tchar[MAXPATHLEN]); + std::unique_ptr<NS_tchar[]> pUserProfile(new NS_tchar[MAXPATHLEN]); NS_tstrcpy(pUserProfile.get(), gPatchDirPath); NS_tchar *slash = (NS_tchar *) NS_tstrrchr(pUserProfile.get(), NS_T('/')); if (slash) @@ -4036,7 +4036,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) NS_tsnprintf(searchspec, sizeof(searchspec)/sizeof(searchspec[0]), NS_T("%s*"), dirpath); - std::unique_ptr<const NS_tchar> pszSpec(get_full_path(searchspec)); + std::unique_ptr<const NS_tchar[]> pszSpec(get_full_path(searchspec)); hFindFile = FindFirstFileW(pszSpec.get(), &finddata); if (hFindFile != INVALID_HANDLE_VALUE) @@ -4116,7 +4116,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) char chars[MAXNAMLEN]; } ent_buf; struct dirent* ent; - std::unique_ptr<NS_tchar> searchpath(get_full_path(dirpath)); + std::unique_ptr<NS_tchar[]> searchpath(get_full_path(dirpath)); DIR* dir = opendir(searchpath.get()); if (!dir) @@ -4206,7 +4206,7 @@ int add_dir_entries(const NS_tchar *dirpath, ActionList *list) int rv = OK; FTS *ftsdir; FTSENT *ftsdirEntry; - std::unique_ptr<NS_tchar> searchpath(get_full_path(dirpath)); + std::unique_ptr<NS_tchar[]> searchpath(get_full_path(dirpath)); // Remove the trailing slash so the paths don't contain double slashes. The // existence of the slash has already been checked in DoUpdate. @@ -4384,10 +4384,10 @@ GetManifestContents(const NS_tchar *manifest) int AddPreCompleteActions(ActionList *list) { #ifdef MACOSX - std::unique_ptr<NS_tchar> manifestPath(get_full_path( + std::unique_ptr<NS_tchar[]> manifestPath(get_full_path( NS_T("Contents/Resources/precomplete"))); #else - std::unique_ptr<NS_tchar> manifestPath(get_full_path( + std::unique_ptr<NS_tchar[]> manifestPath(get_full_path( NS_T("precomplete"))); #endif diff --git a/vcl/opengl/win/WinDeviceInfo.cxx b/vcl/opengl/win/WinDeviceInfo.cxx index 29439b9ae43a..2a36d57ce9dd 100644 --- a/vcl/opengl/win/WinDeviceInfo.cxx +++ b/vcl/opengl/win/WinDeviceInfo.cxx @@ -211,7 +211,7 @@ int32_t WindowsOSVersion() dwCount = GetFileVersionInfoSizeW(szPath, nullptr); if (dwCount != 0) { - std::unique_ptr<char> ver(new char[dwCount]); + std::unique_ptr<char[]> ver(new char[dwCount]); if (GetFileVersionInfoW(szPath, 0, dwCount, ver.get()) != FALSE) { void* pBlock = nullptr; diff --git a/vcl/win/app/salinst.cxx b/vcl/win/app/salinst.cxx index af97c82f752e..0f422f3cfc72 100644 --- a/vcl/win/app/salinst.cxx +++ b/vcl/win/app/salinst.cxx @@ -1057,7 +1057,7 @@ OUString WinSalInstance::getOSVersion() dwCount = GetFileVersionInfoSizeW(szPath, nullptr); if (dwCount != 0) { - std::unique_ptr<char> ver(new char[dwCount]); + std::unique_ptr<char[]> ver(new char[dwCount]); if (GetFileVersionInfoW(szPath, 0, dwCount, ver.get()) != FALSE) { void* pBlock = nullptr; diff --git a/vcl/win/window/salframe.cxx b/vcl/win/window/salframe.cxx index 7b50f7f4cd09..ef6d7ff2827a 100644 --- a/vcl/win/window/salframe.cxx +++ b/vcl/win/window/salframe.cxx @@ -4987,12 +4987,12 @@ static bool ImplHandleIMECompositionInput( WinSalFrame* pFrame, if ( nTextLen > 0 ) { { - auto pTextBuf = std::unique_ptr<WCHAR>(new WCHAR[nTextLen]); + auto pTextBuf = std::unique_ptr<WCHAR[]>(new WCHAR[nTextLen]); ImmGetCompositionStringW( hIMC, GCS_COMPSTR, pTextBuf.get(), nTextLen*sizeof( WCHAR ) ); aEvt.maText = OUString( o3tl::toU(pTextBuf.get()), static_cast<sal_Int32>(nTextLen) ); } - std::unique_ptr<BYTE> pAttrBuf; + std::unique_ptr<BYTE[]> pAttrBuf; LONG nAttrLen = ImmGetCompositionStringW( hIMC, GCS_COMPATTR, nullptr, 0 ); if ( nAttrLen > 0 ) { |