diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2016-03-10 16:47:16 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2016-03-10 21:41:23 +0100 |
commit | 81dd7115e8da9a365a2d26e225f6ec4d2d8ccb5f (patch) | |
tree | 57478c3ad729c211811fdcd27c957d7fca9da944 /jvmfwk | |
parent | 624f9696a9d18480f04cca85c174099dbb8dbee5 (diff) |
Manage JavaInfo instances via new/delete
Change-Id: I10a113718e525b646c51aa8a19f9f2b75a36714a
Diffstat (limited to 'jvmfwk')
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 4 | ||||
-rw-r--r-- | jvmfwk/source/elements.cxx | 4 | ||||
-rw-r--r-- | jvmfwk/source/framework.cxx | 18 |
3 files changed, 9 insertions, 17 deletions
diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 89e1a49bd1ed..e69420334736 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -146,9 +146,7 @@ OString getPluginJarPath( JavaInfo* createJavaInfo(const rtl::Reference<VendorBase> & info) { - JavaInfo* pInfo = static_cast<JavaInfo*>(rtl_allocateMemory(sizeof(JavaInfo))); - if (pInfo == nullptr) - return nullptr; + JavaInfo* pInfo = new JavaInfo; OUString sVendor = info->getVendor(); pInfo->sVendor = sVendor.pData; rtl_uString_acquire(sVendor.pData); diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index 3e9f478c58ea..60a1fa5cbe21 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -977,9 +977,7 @@ JavaInfo * CNodeJavaInfo::makeJavaInfo() const { if (bNil || m_bEmptyNode) return nullptr; - JavaInfo * pInfo = static_cast<JavaInfo*>(rtl_allocateMemory(sizeof(JavaInfo))); - if (pInfo == nullptr) - return nullptr; + JavaInfo * pInfo = new JavaInfo; memset(pInfo, 0, sizeof(JavaInfo)); pInfo->sVendor = sVendor.pData; rtl_uString_acquire(pInfo->sVendor); diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index f28092a59b28..e70e831e54b2 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -655,7 +655,7 @@ void jfw_freeJavaInfo(JavaInfo *pInfo) rtl_uString_release(pInfo->sLocation); rtl_uString_release(pInfo->sVersion); rtl_byte_sequence_release(pInfo->arVendorData); - rtl_freeMemory(pInfo); + delete pInfo; } javaFrameworkError jfw_getSelectedJRE(JavaInfo **ppInfo) @@ -1081,16 +1081,12 @@ JavaInfo * CJavaInfo::copyJavaInfo(const JavaInfo * pInfo) { if (pInfo == nullptr) return nullptr; - JavaInfo* newInfo = - static_cast<JavaInfo*>(rtl_allocateMemory(sizeof(JavaInfo))); - if (newInfo) - { - memcpy(newInfo, pInfo, sizeof(JavaInfo)); - rtl_uString_acquire(pInfo->sVendor); - rtl_uString_acquire(pInfo->sLocation); - rtl_uString_acquire(pInfo->sVersion); - rtl_byte_sequence_acquire(pInfo->arVendorData); - } + JavaInfo* newInfo = new JavaInfo; + memcpy(newInfo, pInfo, sizeof(JavaInfo)); + rtl_uString_acquire(pInfo->sVendor); + rtl_uString_acquire(pInfo->sLocation); + rtl_uString_acquire(pInfo->sVersion); + rtl_byte_sequence_acquire(pInfo->arVendorData); return newInfo; } |