diff --git a/src/CachedReader.cpp b/src/CachedReader.cpp index 96e0486..d1971a7 100644 --- a/src/CachedReader.cpp +++ b/src/CachedReader.cpp @@ -7,7 +7,7 @@ //#define NO_CACHE -CachedReader::CachedReader(std::shared_ptr reader, CacheZone* zone, const std::string& tag) +CachedReader::CachedReader(std::shared_ptr reader, std::shared_ptr zone, const std::string& tag) : m_reader(reader), m_zone(zone), m_tag(tag) { } diff --git a/src/CachedReader.h b/src/CachedReader.h index 66221d3..54addfb 100644 --- a/src/CachedReader.h +++ b/src/CachedReader.h @@ -7,7 +7,7 @@ class CachedReader : public Reader { public: - CachedReader(std::shared_ptr reader, CacheZone* zone, const std::string& tag); + CachedReader(std::shared_ptr reader, std::shared_ptr zone, const std::string& tag); virtual int32_t read(void* buf, int32_t count, uint64_t offset) override; virtual uint64_t length() override; @@ -15,7 +15,7 @@ class CachedReader : public Reader void nonCachedRead(void* buf, int32_t count, uint64_t offset); private: std::shared_ptr m_reader; - CacheZone* m_zone; + std::shared_ptr m_zone; const std::string m_tag; }; diff --git a/src/DMGDisk.cpp b/src/DMGDisk.cpp index 7cd143d..c44dc24 100644 --- a/src/DMGDisk.cpp +++ b/src/DMGDisk.cpp @@ -15,7 +15,7 @@ #include "exceptions.h" DMGDisk::DMGDisk(std::shared_ptr reader) - : m_reader(reader), m_zone(40000) + : m_reader(reader), m_zone(std::make_shared(40000)) { uint64_t offset = m_reader->length(); @@ -244,11 +244,11 @@ std::shared_ptr DMGDisk::readerForPartition(int index) m_reader->length() - data_offset)); return std::shared_ptr( - new CachedReader(std::shared_ptr(new DMGPartition(r, table)), &m_zone, partName.str()) + new CachedReader(std::shared_ptr(new DMGPartition(r, table)), m_zone, partName.str()) ); } else { return std::shared_ptr( - new CachedReader(std::shared_ptr(new DMGPartition(m_reader, table)), &m_zone, partName.str()) + new CachedReader(std::shared_ptr(new DMGPartition(m_reader, table)), m_zone, partName.str()) ); } } diff --git a/src/DMGDisk.h b/src/DMGDisk.h index a209a21..b0ffdf9 100644 --- a/src/DMGDisk.h +++ b/src/DMGDisk.h @@ -29,7 +29,7 @@ class DMGDisk : public PartitionedDisk std::vector m_partitions; UDIFResourceFile m_udif; xmlDocPtr m_kolyXML; - CacheZone m_zone; + std::shared_ptr m_zone; }; #endif diff --git a/src/HFSAttributeBTree.cpp b/src/HFSAttributeBTree.cpp index 45a38dc..7f45a23 100644 --- a/src/HFSAttributeBTree.cpp +++ b/src/HFSAttributeBTree.cpp @@ -4,7 +4,7 @@ #include #include "unichar.h" using icu::UnicodeString; -HFSAttributeBTree::HFSAttributeBTree(std::shared_ptr fork, CacheZone* zone) +HFSAttributeBTree::HFSAttributeBTree(std::shared_ptr fork, std::shared_ptr zone) : HFSBTree(fork, zone, "Attribute") { } diff --git a/src/HFSAttributeBTree.h b/src/HFSAttributeBTree.h index 2f0b5b7..b90044b 100644 --- a/src/HFSAttributeBTree.h +++ b/src/HFSAttributeBTree.h @@ -11,7 +11,7 @@ class HFSAttributeBTree : protected HFSBTree { public: - HFSAttributeBTree(std::shared_ptr fork, CacheZone* zone); + HFSAttributeBTree(std::shared_ptr fork, std::shared_ptr zone); typedef std::map> AttributeMap; diff --git a/src/HFSBTree.cpp b/src/HFSBTree.cpp index 6ae19d2..ae4d1ac 100644 --- a/src/HFSBTree.cpp +++ b/src/HFSBTree.cpp @@ -11,7 +11,7 @@ #include "CacheZone.h" #include "exceptions.h" -HFSBTree::HFSBTree(std::shared_ptr fork, CacheZone* zone, const char* cacheTag) +HFSBTree::HFSBTree(std::shared_ptr fork, std::shared_ptr zone, const char* cacheTag) : m_fork(fork) { BTNodeDescriptor desc0; diff --git a/src/HFSBTree.h b/src/HFSBTree.h index 7205ac3..9818664 100644 --- a/src/HFSBTree.h +++ b/src/HFSBTree.h @@ -13,7 +13,7 @@ class HFSBTree { public: - HFSBTree(std::shared_ptr fork, CacheZone* zone, const char* cacheTag); + HFSBTree(std::shared_ptr fork, std::shared_ptr zone, const char* cacheTag); struct Key { diff --git a/src/HFSCatalogBTree.cpp b/src/HFSCatalogBTree.cpp index 1e0eb96..1cb09d9 100644 --- a/src/HFSCatalogBTree.cpp +++ b/src/HFSCatalogBTree.cpp @@ -10,7 +10,7 @@ static const int MAX_SYMLINKS = 50; extern UConverter *g_utf16be; -HFSCatalogBTree::HFSCatalogBTree(std::shared_ptr fork, HFSVolume* volume, CacheZone* zone) +HFSCatalogBTree::HFSCatalogBTree(std::shared_ptr fork, HFSVolume* volume, std::shared_ptr zone) : HFSBTree(fork, zone, "Catalog"), m_volume(volume), m_hardLinkDirID(0) { HFSPlusCatalogFileOrFolder ff; @@ -265,7 +265,6 @@ int HFSCatalogBTree::stat(std::string path, HFSPlusCatalogFileOrFolder* s) return 0; } -extern int mustbreak; void HFSCatalogBTree::appendNameAndHFSPlusCatalogFileOrFolderFromLeafForParentId(std::shared_ptr leafNodePtr, HFSCatalogNodeID cnid, std::map>& map) { diff --git a/src/HFSCatalogBTree.h b/src/HFSCatalogBTree.h index 914db4d..cb30299 100644 --- a/src/HFSCatalogBTree.h +++ b/src/HFSCatalogBTree.h @@ -14,7 +14,7 @@ class HFSCatalogBTree : protected HFSBTree { public: // using HFSBTree::HFSBTree; - HFSCatalogBTree(std::shared_ptr fork, HFSVolume* volume, CacheZone* zone); + HFSCatalogBTree(std::shared_ptr fork, HFSVolume* volume, std::shared_ptr zone); int listDirectory(const std::string& path, std::map>& contents); diff --git a/src/HFSExtentsOverflowBTree.cpp b/src/HFSExtentsOverflowBTree.cpp index dc88723..0b657aa 100644 --- a/src/HFSExtentsOverflowBTree.cpp +++ b/src/HFSExtentsOverflowBTree.cpp @@ -3,7 +3,7 @@ #include "exceptions.h" #include -HFSExtentsOverflowBTree::HFSExtentsOverflowBTree(std::shared_ptr fork, CacheZone* zone) +HFSExtentsOverflowBTree::HFSExtentsOverflowBTree(std::shared_ptr fork, std::shared_ptr zone) : HFSBTree(fork, zone, "ExtentsOverflow") { } diff --git a/src/HFSExtentsOverflowBTree.h b/src/HFSExtentsOverflowBTree.h index c2cab69..81d40fd 100644 --- a/src/HFSExtentsOverflowBTree.h +++ b/src/HFSExtentsOverflowBTree.h @@ -9,7 +9,7 @@ class HFSExtentsOverflowBTree : protected HFSBTree { public: - HFSExtentsOverflowBTree(std::shared_ptr fork, CacheZone* zone); + HFSExtentsOverflowBTree(std::shared_ptr fork, std::shared_ptr zone); void findExtentsForFile(HFSCatalogNodeID cnid, bool resourceFork, uint32_t startBlock, std::vector& extraExtents); private: static int cnidComparator(const Key* indexKey, const Key* desiredKey); diff --git a/src/HFSVolume.cpp b/src/HFSVolume.cpp index aef04c8..5300be5 100644 --- a/src/HFSVolume.cpp +++ b/src/HFSVolume.cpp @@ -10,7 +10,7 @@ HFSVolume::HFSVolume(std::shared_ptr reader) : m_reader(reader), m_embeddedReader(nullptr), m_overflowExtents(nullptr), m_attributes(nullptr), - m_fileZone(6400), m_btreeZone(6400) + m_fileZone(std::make_shared(6400)), m_btreeZone(std::make_shared(6400)) { static_assert(sizeof(HFSPlusVolumeHeader) >= sizeof(HFSMasterDirectoryBlock), "Bad read is about to happen"); @@ -27,12 +27,12 @@ HFSVolume::HFSVolume(std::shared_ptr reader) throw io_error("Invalid HFS+/HFSX signature"); std::shared_ptr fork (new HFSFork(this, m_header.extentsFile)); - m_overflowExtents = new HFSExtentsOverflowBTree(fork, &m_btreeZone); + m_overflowExtents = new HFSExtentsOverflowBTree(fork, m_btreeZone); if (m_header.attributesFile.logicalSize != 0) { fork.reset(new HFSFork(this, m_header.attributesFile, kHFSAttributesFileID)); - m_attributes = new HFSAttributeBTree(fork, &m_btreeZone); + m_attributes = new HFSAttributeBTree(fork, m_btreeZone); } } @@ -93,7 +93,7 @@ void HFSVolume::usage(uint64_t& totalBytes, uint64_t& freeBytes) const HFSCatalogBTree* HFSVolume::rootCatalogTree() { std::shared_ptr fork (new HFSFork(this, m_header.catalogFile, kHFSCatalogFileID)); - HFSCatalogBTree* btree = new HFSCatalogBTree(fork, this, &m_btreeZone); + HFSCatalogBTree* btree = new HFSCatalogBTree(fork, this, m_btreeZone); return btree; } diff --git a/src/HFSVolume.h b/src/HFSVolume.h index 92af27f..b4ce914 100644 --- a/src/HFSVolume.h +++ b/src/HFSVolume.h @@ -27,8 +27,8 @@ class HFSVolume static bool isHFSPlus(std::shared_ptr reader); - inline CacheZone* getFileZone() { return &m_fileZone; } - inline CacheZone* getBtreeZone() { return &m_btreeZone; } + inline std::shared_ptr getFileZone() { return m_fileZone; } + inline std::shared_ptr getBtreeZone() { return m_btreeZone; } private: void processEmbeddedHFSPlus(HFSMasterDirectoryBlock* block); private: @@ -37,7 +37,7 @@ class HFSVolume HFSExtentsOverflowBTree* m_overflowExtents; HFSAttributeBTree* m_attributes; HFSPlusVolumeHeader m_header; - CacheZone m_fileZone, m_btreeZone; + std::shared_ptr m_fileZone, m_btreeZone; friend class HFSBTree; friend class HFSFork;