Change the constructor of CacheReader.
diff --git a/lib/bcc/CacheReader.cpp b/lib/bcc/CacheReader.cpp
index 14dd03e..ddb0258 100644
--- a/lib/bcc/CacheReader.cpp
+++ b/lib/bcc/CacheReader.cpp
@@ -51,14 +51,14 @@
if (mpFuncTable) { free(mpFuncTable); }
}
-ScriptCached *CacheReader::readCacheFile(FileHandle *file) {
+ScriptCached *CacheReader::readCacheFile(FileHandle *file, Script *S) {
// Check file handle
if (!file || file->getFD() < 0) {
return NULL;
}
// Allocate ScriptCached object
- mpResult.reset(new (nothrow) ScriptCached(mpOwner));
+ mpResult.reset(new (nothrow) ScriptCached(S));
if (!mpResult) {
LOGE("Unable to allocate ScriptCached object.\n");
diff --git a/lib/bcc/CacheReader.h b/lib/bcc/CacheReader.h
index cfd32e3..3f052d0 100644
--- a/lib/bcc/CacheReader.h
+++ b/lib/bcc/CacheReader.h
@@ -36,8 +36,6 @@
class CacheReader {
private:
- Script *mpOwner;
-
FileHandle *mFile;
off_t mFileSize;
@@ -52,8 +50,8 @@
std::pair<uint32_t, unsigned char const *> > mDependencies;
public:
- CacheReader(Script *owner)
- : mpOwner(owner), mFile(NULL), mFileSize(0), mpHeader(NULL),
+ CacheReader()
+ : mFile(NULL), mFileSize(0), mpHeader(NULL),
mpCachedDependTable(NULL), mpPragmaList(NULL), mpFuncTable(NULL) {
}
@@ -66,7 +64,7 @@
std::make_pair((uint32_t)resType, sha1)));
}
- ScriptCached *readCacheFile(FileHandle *file);
+ ScriptCached *readCacheFile(FileHandle *file, Script *s);
private:
bool readHeader();
diff --git a/lib/bcc/Script.cpp b/lib/bcc/Script.cpp
index d9faf02..789fb01 100644
--- a/lib/bcc/Script.cpp
+++ b/lib/bcc/Script.cpp
@@ -192,7 +192,7 @@
return 1;
}
- CacheReader reader(this);
+ CacheReader reader;
// Dependencies
reader.addDependency(BCC_FILE_RESOURCE, pathLibBCC, sha1LibBCC);
@@ -204,7 +204,7 @@
}
// Read cache file
- ScriptCached *cached = reader.readCacheFile(&file);
+ ScriptCached *cached = reader.readCacheFile(&file, this);
if (!cached) {
return 1;
}