AuroraRuntime/Source/Memory/AuHeapInternal.hpp

66 lines
2.0 KiB
C++

/***
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(AuUInt uLength);
virtual ~InternalHeap();
bool Init(const MemoryViewWrite &memory);
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:
O1HeapInstance *pHeap_ {};
std::shared_ptr<MemoryViewWrite> pBloat_;
protected:
AuUInt32 uAllocCount_ {};
bool bOwnsMemory_ {};
bool bIsDangling_ {};
};
}