From 13180e0c7cdfbaa86b8380fe7e8966f8ebaf1e00 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 13 Apr 2017 17:01:13 +0200 Subject: Use std::unique_ptr in createJavaInfo Change-Id: Ie39c40e0fd05f75e734d8cd2d33a7fb13c746f77 --- .../plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 32 ++++++++++------------ 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'jvmfwk/plugins') diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 273db8f5a99e..a725b2cec55d 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -148,14 +148,9 @@ OString getPluginJarPath( #endif // UNX -JavaInfo* createJavaInfo(const rtl::Reference & info) +std::unique_ptr createJavaInfo( + const rtl::Reference & info) { - JavaInfo* pInfo = new JavaInfo; - pInfo->sVendor = info->getVendor(); - pInfo->sLocation = info->getHome(); - pInfo->sVersion = info->getVersion(); - pInfo->nFeatures = info->supportsAccessibility() ? 1 : 0; - pInfo->nRequirements = info->needsRestart() ? JFW_REQUIRE_NEEDRESTART : 0; OUStringBuffer buf(1024); buf.append(info->getRuntimeLibrary()); if (!info->getLibraryPath().isEmpty()) @@ -164,13 +159,15 @@ JavaInfo* createJavaInfo(const rtl::Reference & info) buf.append(info->getLibraryPath()); buf.append("\n"); } - OUString sVendorData = buf.makeStringAndClear(); - pInfo->arVendorData = rtl::ByteSequence( - reinterpret_cast(sVendorData.pData->buffer), - sVendorData.getLength() * sizeof(sal_Unicode)); - - return pInfo; + return std::unique_ptr( + new JavaInfo{ + info->getVendor(), info->getHome(), info->getVersion(), + sal_uInt64(info->supportsAccessibility() ? 1 : 0), + sal_uInt64(info->needsRestart() ? JFW_REQUIRE_NEEDRESTART : 0), + rtl::ByteSequence( + reinterpret_cast(sVendorData.pData->buffer), + sVendorData.getLength() * sizeof(sal_Unicode))}); } OUString getRuntimeLib(const rtl::ByteSequence & data) @@ -337,7 +334,7 @@ javaPluginError jfw_plugin_getAllJavaInfos( typedef vector >::const_iterator cit; for (cit ii = vecVerifiedInfos.begin(); ii != vecVerifiedInfos.end(); ++ii) { - parJavaInfo->push_back(std::unique_ptr(createJavaInfo(*ii))); + parJavaInfo->push_back(createJavaInfo(*ii)); } return javaPluginError::NONE; @@ -371,7 +368,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath( aVendorInfo, sMinVersion, sMaxVersion, arExcludeList); if (errorcode == javaPluginError::NONE) - ppInfo->reset(createJavaInfo(aVendorInfo)); + *ppInfo = createJavaInfo(aVendorInfo); return errorcode; } @@ -407,7 +404,7 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome( if (errorcode == javaPluginError::NONE) { - ppInfo->reset(createJavaInfo(infoJavaHome[0])); + *ppInfo = createJavaInfo(infoJavaHome[0]); return javaPluginError::NONE; } } @@ -449,8 +446,7 @@ javaPluginError jfw_plugin_getJavaInfosFromPath( if (errorcode == javaPluginError::NONE) { - vecVerifiedInfos.push_back( - std::unique_ptr(createJavaInfo(currentInfo))); + vecVerifiedInfos.push_back(createJavaInfo(currentInfo)); } } } -- cgit