diff options
author | Richard Uhler <ruhler@google.com> | 2014-12-23 09:48:51 -0800 |
---|---|---|
committer | Richard Uhler <ruhler@google.com> | 2015-01-13 16:32:34 -0800 |
commit | fbef44de596d298dc6430f482dffc933a046dd28 (patch) | |
tree | 57345e86b7dda80b82a263069230b7e312db5ef2 /runtime/dex_file.h | |
parent | 603104b5b5c3759b0bc2733bda2f972686a775a3 (diff) | |
download | android_art-fbef44de596d298dc6430f482dffc933a046dd28.tar.gz android_art-fbef44de596d298dc6430f482dffc933a046dd28.tar.bz2 android_art-fbef44de596d298dc6430f482dffc933a046dd28.zip |
Use unique_ptr to track ownership of dex files.
Bug: 18809837
Change-Id: Ie571eae8fc19ee9207390cff5c7e2a38071b126a
Diffstat (limited to 'runtime/dex_file.h')
-rw-r--r-- | runtime/dex_file.h | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/runtime/dex_file.h b/runtime/dex_file.h index a71ca429cb..019c8e6e9a 100644 --- a/runtime/dex_file.h +++ b/runtime/dex_file.h @@ -385,19 +385,20 @@ class DexFile { // Opens .dex files found in the container, guessing the container format based on file extension. static bool Open(const char* filename, const char* location, std::string* error_msg, - std::vector<const DexFile*>* dex_files); + std::vector<std::unique_ptr<const DexFile>>* dex_files); // Opens .dex file, backed by existing memory - static const DexFile* Open(const uint8_t* base, size_t size, - const std::string& location, - uint32_t location_checksum, - std::string* error_msg) { + static std::unique_ptr<const DexFile> Open(const uint8_t* base, size_t size, + const std::string& location, + uint32_t location_checksum, + std::string* error_msg) { return OpenMemory(base, size, location, location_checksum, NULL, error_msg); } // Open all classesXXX.dex files from a zip archive. static bool OpenFromZip(const ZipArchive& zip_archive, const std::string& location, - std::string* error_msg, std::vector<const DexFile*>* dex_files); + std::string* error_msg, + std::vector<std::unique_ptr<const DexFile>>* dex_files); // Closes a .dex file. virtual ~DexFile(); @@ -892,11 +893,12 @@ class DexFile { private: // Opens a .dex file - static const DexFile* OpenFile(int fd, const char* location, bool verify, std::string* error_msg); + static std::unique_ptr<const DexFile> OpenFile(int fd, const char* location, + bool verify, std::string* error_msg); // Opens dex files from within a .jar, .zip, or .apk file static bool OpenZip(int fd, const std::string& location, std::string* error_msg, - std::vector<const DexFile*>* dex_files); + std::vector<std::unique_ptr<const DexFile>>* dex_files); enum class ZipOpenErrorCode { // private kNoError, @@ -909,23 +911,23 @@ class DexFile { // Opens .dex file from the entry_name in a zip archive. error_code is undefined when non-nullptr // return. - static const DexFile* Open(const ZipArchive& zip_archive, const char* entry_name, - const std::string& location, std::string* error_msg, - ZipOpenErrorCode* error_code); + static std::unique_ptr<const DexFile> Open(const ZipArchive& zip_archive, const char* entry_name, + const std::string& location, std::string* error_msg, + ZipOpenErrorCode* error_code); // Opens a .dex file at the given address backed by a MemMap - static const DexFile* OpenMemory(const std::string& location, - uint32_t location_checksum, - MemMap* mem_map, - std::string* error_msg); + static std::unique_ptr<const DexFile> OpenMemory(const std::string& location, + uint32_t location_checksum, + MemMap* mem_map, + std::string* error_msg); // Opens a .dex file at the given address, optionally backed by a MemMap - static const DexFile* OpenMemory(const uint8_t* dex_file, - size_t size, - const std::string& location, - uint32_t location_checksum, - MemMap* mem_map, - std::string* error_msg); + static std::unique_ptr<const DexFile> OpenMemory(const uint8_t* dex_file, + size_t size, + const std::string& location, + uint32_t location_checksum, + MemMap* mem_map, + std::string* error_msg); DexFile(const uint8_t* base, size_t size, const std::string& location, |