AuroraRuntime/Source/Memory/AuHeapInternal.hpp

68 lines
2.1 KiB
C++
Raw Permalink Normal View History

2024-03-19 15:47:42 +00:00
/***
Copyright (C) 2021-2024 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: AuHeapInternal.hpp
File: Heap.hpp
Date: 2021-6-12
Author: Reece
***/
#pragma once
#include "AuMemory.hpp"
#include "AuBaseHeap.hpp"
#include "o1heap.hpp"
namespace Aurora::Memory
{
struct InternalHeap :
BaseHeap,
AuEnableSharedFromThis<InternalHeap>
{
virtual AuSPtr<Heap> AllocateDivision(AuUInt32 heap, AuUInt32 alignment) override;
InternalHeap();
InternalHeap(const MemoryViewWrite &memory);
InternalHeap(const AuSPtr<MemoryViewWrite> &pMemory);
2024-03-19 15:47:42 +00:00
InternalHeap(AuUInt uLength);
virtual ~InternalHeap();
2024-04-15 16:51:22 +00:00
bool Init(const MemoryViewWrite &memory);
bool Init(const AuSPtr<MemoryViewWrite> &pMemory);
2024-03-19 15:47:42 +00:00
bool Init(AuUInt uLength, void *ptr = nullptr);
static AuUInt GetHeapSize(const void *ptr);
Types::size_t GetChunkSize(const void *head) override;
void *_FAlloc(Types::size_t uLength) override;
void *_FAlloc(Types::size_t uLength, Types::size_t uAlign) override;
void *_ZAlloc(Types::size_t uLength) override;
void *_ZAlloc(Types::size_t uLength, Types::size_t uAlign) override;
void *_ZRealloc(void *pBuffer, Types::size_t uLength) override;
void *_ZRealloc(void *pBuffer, Types::size_t uLength, Types::size_t uAlign) override;
void *_FRealloc(void *pBuffer, Types::size_t uLength) override;
void *_FRealloc(void *pBuffer, Types::size_t uLength, Types::size_t uAlign) override;
void _Free(void *pBuffer) override;
AuSPtr<Heap> GetSelfReference() override;
Heap *GetSelfReferenceRaw() override;
void TryRelease();
void DecrementUsers();
void RequestTermination();
void UpdateStats() override;
void WalkHeap(bool(*fCallback)(void *, void *), void *pSecondArg) override;
private:
2024-04-15 16:51:22 +00:00
O1HeapInstance *pHeap_ {};
std::shared_ptr<MemoryViewWrite> pBloat_;
2024-03-19 15:47:42 +00:00
protected:
2024-04-15 16:51:22 +00:00
AuUInt32 uAllocCount_ {};
2024-03-19 15:47:42 +00:00
bool bOwnsMemory_ {};
2024-04-15 16:51:22 +00:00
bool bIsDangling_ {};
2024-03-19 15:47:42 +00:00
};
}