Turn JavaInfo sal_Sequence* member into rtl::ByteSequence

Change-Id: Iecd476970b0b7a46afe223f71e95b0010048d7b1
This commit is contained in:
Stephan Bergmann
2016-03-10 17:32:48 +01:00
parent 5dcdb35ab1
commit 8546831b3b
4 changed files with 10 additions and 20 deletions

View File

@@ -23,6 +23,7 @@
#define INCLUDED_JVMFWK_FRAMEWORK_HXX #define INCLUDED_JVMFWK_FRAMEWORK_HXX
#include <jvmfwk/jvmfwkdllapi.hxx> #include <jvmfwk/jvmfwkdllapi.hxx>
#include <rtl/byteseq.hxx>
#include <rtl/ustring.h> #include <rtl/ustring.h>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <osl/mutex.h> #include <osl/mutex.h>
@@ -207,8 +208,7 @@ typedef enum _javaFrameworkError
<p> <p>
Instances of this struct are created by the plug-in libraries which are used by Instances of this struct are created by the plug-in libraries which are used by
this framework (jvmfwk/vendorplugin.h). The contained members must be this framework (jvmfwk/vendorplugin.h).
freed individually.
For convenience this API provides the function <code>jfw_freeJavaInfo</code> For convenience this API provides the function <code>jfw_freeJavaInfo</code>
which frees the objects properly. </p> which frees the objects properly. </p>
*/ */
@@ -254,7 +254,7 @@ struct JavaInfo
values. The plug-in libraries can put all data, necessary for values. The plug-in libraries can put all data, necessary for
starting the java runtime into this sequence. </p> starting the java runtime into this sequence. </p>
*/ */
sal_Sequence * arVendorData; rtl::ByteSequence arVendorData;
}; };
/** frees the memory of a <code>JavaInfo</code> object. /** frees the memory of a <code>JavaInfo</code> object.
@@ -271,7 +271,7 @@ JVMFWK_DLLPUBLIC void jfw_freeJavaInfo(JavaInfo *pInfo);
in the second <code>JavaInfo</code> object. The equality of the in the second <code>JavaInfo</code> object. The equality of the
<code>OUString</code> members is determined <code>OUString</code> members is determined
by <code>operator ==</code>. by <code>operator ==</code>.
Similarly the equality of the <code>sal_Sequence</code> is Similarly the equality of the <code>rtl::ByteSequence</code> is
also determined by a comparison also determined by a comparison
function (see <code>rtl::ByteSequence::operator ==</code>). </p> function (see <code>rtl::ByteSequence::operator ==</code>). </p>
<p> <p>

View File

@@ -162,10 +162,9 @@ JavaInfo* createJavaInfo(const rtl::Reference<VendorBase> & info)
} }
OUString sVendorData = buf.makeStringAndClear(); OUString sVendorData = buf.makeStringAndClear();
rtl::ByteSequence byteSeq( reinterpret_cast<sal_Int8*>(sVendorData.pData->buffer), pInfo->arVendorData = rtl::ByteSequence(
sVendorData.getLength() * sizeof(sal_Unicode)); reinterpret_cast<sal_Int8*>(sVendorData.pData->buffer),
pInfo->arVendorData = byteSeq.get(); sVendorData.getLength() * sizeof(sal_Unicode));
rtl_byte_sequence_acquire(pInfo->arVendorData);
return pInfo; return pInfo;
} }

View File

@@ -984,8 +984,7 @@ JavaInfo * CNodeJavaInfo::makeJavaInfo() const
pInfo->sVersion = sVersion; pInfo->sVersion = sVersion;
pInfo->nFeatures = nFeatures; pInfo->nFeatures = nFeatures;
pInfo->nRequirements = nRequirements; pInfo->nRequirements = nRequirements;
pInfo->arVendorData = arVendorData.getHandle(); pInfo->arVendorData = arVendorData;
rtl_byte_sequence_acquire(pInfo->arVendorData);
return pInfo; return pInfo;
} }

View File

@@ -630,13 +630,12 @@ bool jfw_areEqualJavaInfo(JavaInfo const * pInfoA,JavaInfo const * pInfoB)
return true; return true;
if (pInfoA == nullptr || pInfoB == nullptr) if (pInfoA == nullptr || pInfoB == nullptr)
return false; return false;
rtl::ByteSequence sData(pInfoA->arVendorData);
if (pInfoA->sVendor == pInfoB->sVendor if (pInfoA->sVendor == pInfoB->sVendor
&& pInfoA->sLocation == pInfoB->sLocation && pInfoA->sLocation == pInfoB->sLocation
&& pInfoA->sVersion == pInfoB->sVersion && pInfoA->sVersion == pInfoB->sVersion
&& pInfoA->nFeatures == pInfoB->nFeatures && pInfoA->nFeatures == pInfoB->nFeatures
&& pInfoA->nRequirements == pInfoB->nRequirements && pInfoA->nRequirements == pInfoB->nRequirements
&& sData == pInfoB->arVendorData) && pInfoA->arVendorData == pInfoB->arVendorData)
{ {
return true; return true;
} }
@@ -646,9 +645,6 @@ bool jfw_areEqualJavaInfo(JavaInfo const * pInfoA,JavaInfo const * pInfoB)
void jfw_freeJavaInfo(JavaInfo *pInfo) void jfw_freeJavaInfo(JavaInfo *pInfo)
{ {
if (pInfo == nullptr)
return;
rtl_byte_sequence_release(pInfo->arVendorData);
delete pInfo; delete pInfo;
} }
@@ -1073,11 +1069,7 @@ CJavaInfo::~CJavaInfo()
JavaInfo * CJavaInfo::copyJavaInfo(const JavaInfo * pInfo) JavaInfo * CJavaInfo::copyJavaInfo(const JavaInfo * pInfo)
{ {
if (pInfo == nullptr) return pInfo == nullptr ? nullptr : new JavaInfo(*pInfo);
return nullptr;
JavaInfo* newInfo = new JavaInfo(*pInfo);
rtl_byte_sequence_acquire(newInfo->arVendorData);
return newInfo;
} }