Merge pull request #6390 from aws-lumberyard-dev/memory/overrideshim_removal

Memory/overrideshim removal
This commit is contained in:
Esteban Papp
2022-01-26 08:15:20 -08:00
committed by GitHub
63 changed files with 311 additions and 1231 deletions
@@ -1975,7 +1975,7 @@ namespace AZ::IO
AZ_Error("Archive", false, "OSAllocator is not ready. It cannot be used to allocate a MemoryBlock");
return {};
}
AZ::IAllocatorAllocate* allocator = &AZ::AllocatorInstance<AZ::OSAllocator>::Get();
AZ::IAllocator* allocator = &AZ::AllocatorInstance<AZ::OSAllocator>::Get();
AZStd::intrusive_ptr<AZ::IO::MemoryBlock> memoryBlock{ new (allocator->Allocate(sizeof(AZ::IO::MemoryBlock), alignof(AZ::IO::MemoryBlock))) AZ::IO::MemoryBlock{AZ::IO::MemoryBlockDeleter{ &AZ::AllocatorInstance<AZ::OSAllocator>::Get() }} };
auto CreateFunc = [](size_t byteSize, size_t byteAlignment, const char* name)
{
@@ -36,7 +36,7 @@ namespace AZ::IO
struct MemoryBlockDeleter
{
void operator()(const AZStd::intrusive_refcount<AZStd::atomic_uint, MemoryBlockDeleter>* ptr) const;
AZ::IAllocatorAllocate* m_allocator{};
AZ::IAllocator* m_allocator{};
};
struct MemoryBlock
: AZStd::intrusive_refcount<AZStd::atomic_uint, MemoryBlockDeleter>
@@ -42,7 +42,7 @@ namespace AZ::IO::ZipDir
AZ_Error("Archive", false, "OSAllocator is not ready. It cannot be used to allocate a MemoryBlock");
return {};
}
AZ::IAllocatorAllocate* allocator = &AZ::AllocatorInstance<AZ::OSAllocator>::Get();
AZ::IAllocator* allocator = &AZ::AllocatorInstance<AZ::OSAllocator>::Get();
AZStd::intrusive_ptr<AZ::IO::MemoryBlock> memoryBlock{ new (allocator->Allocate(sizeof(AZ::IO::MemoryBlock), alignof(AZ::IO::MemoryBlock))) AZ::IO::MemoryBlock{AZ::IO::MemoryBlockDeleter{ &AZ::AllocatorInstance<AZ::OSAllocator>::Get() }} };
auto CreateFunc = [](size_t byteSize, size_t byteAlignment, const char* name)
{
@@ -142,14 +142,14 @@ namespace AZ::IO::ZipDir
{
}
Cache::Cache(AZ::IAllocatorAllocate* allocator)
Cache::Cache(AZ::IAllocator* allocator)
: m_fileHandle(AZ::IO::InvalidHandle)
, m_nFlags(0)
, m_lCDROffset(0)
, m_encryptedHeaders(ZipFile::HEADERS_NOT_ENCRYPTED)
, m_allocator{ allocator }
{
AZ_Assert(allocator, "IAllocatorAllocate object is required in order to allocated memory for the ZipDir Cache operations");
AZ_Assert(allocator, "IAllocator object is required in order to allocated memory for the ZipDir Cache operations");
}
void Cache::Close()
@@ -40,7 +40,7 @@ namespace AZ::IO::ZipDir
inline static constexpr int compressedBlockHeaderSizeInBytes = 4; //number of bytes we need in front of the compressed block to indicate which compressor was used
Cache();
explicit Cache(AZ::IAllocatorAllocate* allocator);
explicit Cache(AZ::IAllocator* allocator);
~Cache()
{
@@ -133,7 +133,7 @@ namespace AZ::IO::ZipDir
friend class FileEntryTransactionAdd;
FileEntryTree m_treeDir;
AZ::IO::HandleType m_fileHandle;
AZ::IAllocatorAllocate* m_allocator;
AZ::IAllocator* m_allocator;
AZ::IO::Path m_strFilePath;
// String Pool for persistently storing paths as long as they reside in the cache
@@ -39,7 +39,7 @@ namespace AZ::IO::ZipDir
{
}
auto FileDataRecord::New(const FileRecord& rThat, AZ::IAllocatorAllocate* allocator) -> AZStd::intrusive_ptr<FileDataRecord>
auto FileDataRecord::New(const FileRecord& rThat, AZ::IAllocator* allocator) -> AZStd::intrusive_ptr<FileDataRecord>
{
auto fileDataRecordAlloc = reinterpret_cast<FileDataRecord*>(allocator->Allocate(
sizeof(FileDataRecord) + rThat.pFileEntryBase->desc.lSizeCompressed,
@@ -28,7 +28,7 @@ namespace AZ::IO::ZipDir
{
void operator()(const AZStd::intrusive_refcount<AZStd::atomic_uint, FileDataRecordDeleter>* ptr) const;
AZ::IAllocatorAllocate* m_allocator{};
AZ::IAllocator* m_allocator{};
};
struct FileDataRecord
: public FileRecord
@@ -36,7 +36,7 @@ namespace AZ::IO::ZipDir
{
FileDataRecord();
static auto New(const FileRecord& rThat, AZ::IAllocatorAllocate* allocator) ->AZStd::intrusive_ptr<FileDataRecord>;
static auto New(const FileRecord& rThat, AZ::IAllocator* allocator) ->AZStd::intrusive_ptr<FileDataRecord>;
void* GetData() {return this + 1; }
};
@@ -25,13 +25,13 @@ namespace AZ::IO::ZipDir::ZipDirStructuresInternal
{
static void* ZlibAlloc(void* userData, uint32_t item, uint32_t size)
{
auto allocator = reinterpret_cast<AZ::IAllocatorAllocate*>(userData);
auto allocator = reinterpret_cast<AZ::IAllocator*>(userData);
return allocator->Allocate(item * size, alignof(uint8_t), 0, "ZLibAlloc");
}
static void ZlibFree(void* userData, void* ptr)
{
auto allocator = reinterpret_cast<AZ::IAllocatorAllocate*>(userData);
auto allocator = reinterpret_cast<AZ::IAllocator*>(userData);
allocator->DeAllocate(ptr);
}
@@ -296,7 +296,7 @@ namespace AZ::IO::ZipDir::ZipDirStructuresInternal
return {};
}
AZ::IAllocatorAllocate* allocator = &AZ::AllocatorInstance<AZ::OSAllocator>::Get();
AZ::IAllocator* allocator = &AZ::AllocatorInstance<AZ::OSAllocator>::Get();
AZStd::intrusive_ptr<AZ::IO::MemoryBlock> memoryBlock{ new (allocator->Allocate(sizeof(AZ::IO::MemoryBlock), alignof(AZ::IO::MemoryBlock))) AZ::IO::MemoryBlock{AZ::IO::MemoryBlockDeleter{ &AZ::AllocatorInstance<AZ::OSAllocator>::Get() }} };
auto CreateFunc = [](size_t byteSize, size_t byteAlignment, const char* name)
{
@@ -451,7 +451,7 @@ namespace AZ::IO::ZipDir
if (GetDiskFreeSpaceA(drive.c_str(),nullptr, &bytesPerSector, nullptr, nullptr))
{
m_nSectorSize = bytesPerSector;
AZ::IAllocatorAllocate& allocator = AZ::AllocatorInstance<AZ::OSAllocator>::Get();
AZ::IAllocator& allocator = AZ::AllocatorInstance<AZ::OSAllocator>::Get();
if (m_pReadTarget)
{
allocator.DeAllocate(m_pReadTarget);