Switch to a local BitcodeTranslator.
The original implementation was using pointers for bitcode lifetime
issues, but we can now use a regular local (non-pointer) variable
instead.
Change-Id: I5b36f813476a5d433d9926dfb91570b8ede15644
diff --git a/rsScriptC.cpp b/rsScriptC.cpp
index 618c0c9..8a13c89 100644
--- a/rsScriptC.cpp
+++ b/rsScriptC.cpp
@@ -53,18 +53,9 @@
ScriptC * sc = (ScriptC *) tls->mScript
ScriptC::ScriptC(Context *rsc) : Script(rsc) {
-#if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE)
- BT = nullptr;
-#endif
}
ScriptC::~ScriptC() {
-#if !defined(RS_COMPATIBILITY_LIB) && !defined(ANDROID_RS_SERIALIZE)
- if (BT) {
- delete BT;
- BT = nullptr;
- }
-#endif
if (mInitialized) {
mRSC->mHal.funcs.script.invokeFreeChildren(mRSC, this);
mRSC->mHal.funcs.script.destroy(mRSC, this);
@@ -353,19 +344,14 @@
// Bug 19734267
mApiLevel = sdkVersion;
- if (BT) {
- delete BT;
- }
- BT = new bcinfo::BitcodeTranslator((const char *)bitcode, bitcodeLen,
- sdkVersion);
- if (!BT->translate()) {
+ bcinfo::BitcodeTranslator BT((const char *)bitcode, bitcodeLen,
+ sdkVersion);
+ if (!BT.translate()) {
ALOGE("Failed to translate bitcode from version: %u", sdkVersion);
- delete BT;
- BT = nullptr;
return false;
}
- bitcode = (const uint8_t *) BT->getTranslatedBitcode();
- bitcodeLen = BT->getTranslatedBitcodeSize();
+ bitcode = (const uint8_t *) BT.getTranslatedBitcode();
+ bitcodeLen = BT.getTranslatedBitcodeSize();
if (kDebugBitcode) {
if (!dumpBitcodeFile(cacheDir, resName, "after", bitcode, bitcodeLen)) {