Kaydet (Commit) b18747fc authored tarafından Jan-Marek Glogowski's avatar Jan-Marek Glogowski Kaydeden (comit) Mike Kaganski

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: 's avatarMike Kaganski <mike.kaganski@collabora.com>
üst 694a6389
......@@ -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 );
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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 )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment