summaryrefslogtreecommitdiffstats
path: root/runtime/dex_file_verifier_test.cc
diff options
context:
space:
mode:
authorRichard Uhler <ruhler@google.com>2014-12-23 09:48:51 -0800
committerRichard Uhler <ruhler@google.com>2015-01-13 16:32:34 -0800
commitfbef44de596d298dc6430f482dffc933a046dd28 (patch)
tree57345e86b7dda80b82a263069230b7e312db5ef2 /runtime/dex_file_verifier_test.cc
parent603104b5b5c3759b0bc2733bda2f972686a775a3 (diff)
downloadart-fbef44de596d298dc6430f482dffc933a046dd28.zip
art-fbef44de596d298dc6430f482dffc933a046dd28.tar.gz
art-fbef44de596d298dc6430f482dffc933a046dd28.tar.bz2
Use unique_ptr to track ownership of dex files.
Bug: 18809837 Change-Id: Ie571eae8fc19ee9207390cff5c7e2a38071b126a
Diffstat (limited to 'runtime/dex_file_verifier_test.cc')
-rw-r--r--runtime/dex_file_verifier_test.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/runtime/dex_file_verifier_test.cc b/runtime/dex_file_verifier_test.cc
index ec1e5f0..00ca8a9 100644
--- a/runtime/dex_file_verifier_test.cc
+++ b/runtime/dex_file_verifier_test.cc
@@ -101,8 +101,9 @@ static inline uint8_t* DecodeBase64(const char* src, size_t* dst_size) {
return dst.release();
}
-static const DexFile* OpenDexFileBase64(const char* base64, const char* location,
- std::string* error_msg) {
+static std::unique_ptr<const DexFile> OpenDexFileBase64(const char* base64,
+ const char* location,
+ std::string* error_msg) {
// decode base64
CHECK(base64 != NULL);
size_t length;
@@ -122,11 +123,11 @@ static const DexFile* OpenDexFileBase64(const char* base64, const char* location
// read dex file
ScopedObjectAccess soa(Thread::Current());
- std::vector<const DexFile*> tmp;
+ std::vector<std::unique_ptr<const DexFile>> tmp;
bool success = DexFile::Open(location, location, error_msg, &tmp);
CHECK(success) << error_msg;
EXPECT_EQ(1U, tmp.size());
- const DexFile* dex_file = tmp[0];
+ std::unique_ptr<const DexFile> dex_file = std::move(tmp[0]);
EXPECT_EQ(PROT_READ, dex_file->GetPermissions());
EXPECT_TRUE(dex_file->IsReadOnly());
return dex_file;
@@ -166,8 +167,9 @@ static void FixUpChecksum(uint8_t* dex_file) {
header->checksum_ = adler_checksum;
}
-static const DexFile* FixChecksumAndOpen(uint8_t* bytes, size_t length, const char* location,
- std::string* error_msg) {
+static std::unique_ptr<const DexFile> FixChecksumAndOpen(uint8_t* bytes, size_t length,
+ const char* location,
+ std::string* error_msg) {
// Check data.
CHECK(bytes != nullptr);
@@ -187,12 +189,12 @@ static const DexFile* FixChecksumAndOpen(uint8_t* bytes, size_t length, const ch
// read dex file
ScopedObjectAccess soa(Thread::Current());
- std::vector<const DexFile*> tmp;
+ std::vector<std::unique_ptr<const DexFile>> tmp;
if (!DexFile::Open(location, location, error_msg, &tmp)) {
return nullptr;
}
EXPECT_EQ(1U, tmp.size());
- const DexFile* dex_file = tmp[0];
+ std::unique_ptr<const DexFile> dex_file = std::move(tmp[0]);
EXPECT_EQ(PROT_READ, dex_file->GetPermissions());
EXPECT_TRUE(dex_file->IsReadOnly());
return dex_file;