Manage JavaInfo instances via new/delete
Change-Id: I10a113718e525b646c51aa8a19f9f2b75a36714a
This commit is contained in:
parent
624f9696a9
commit
81dd7115e8
@ -206,10 +206,8 @@ typedef enum _javaFrameworkError
|
||||
|
||||
<p>
|
||||
Instances of this struct are created by the plug-in libraries which are used by
|
||||
this framework (jvmfwk/vendorplugin.h). The memory of the instances is created
|
||||
by <code>rtl_allocateMemory</code> (rtl/alloc.h). Therefore, the memory must
|
||||
be freed by <code>rtl_freeMemory</code>. Also the contained members must be
|
||||
freed particularly.
|
||||
this framework (jvmfwk/vendorplugin.h). The contained members must be
|
||||
freed individually.
|
||||
For convenience this API provides the function <code>jfw_freeJavaInfo</code>
|
||||
which frees the objects properly. </p>
|
||||
*/
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user