目录

MemoryAllocator

Class Info

class MemoryAllocator

内存分配器。

Public Constructor Summary

Constructor Name

MemoryAllocator()

构造函数。

Public Destructor Summary

Destructor Name

~MemoryAllocator()

析构函数。

Public Method Summary

Qualifier and Type

Method Name and Description

void*

Alloc(u64 size, u64 alignment = alignof(f64))

分配以alignment位数对齐的内存。

inline void

Flush()

释放内存。

template<typename T, u64 ALIGN = alignof(T), typename... ARGS> T*

Allocate(ARGS&& ... args)

分配内存并初始化对象。

void

Free(void* p, u64 size)

释放资源。

Public Constructors

[h2]MemoryAllocator

Constructor

MemoryAllocator()

构造函数。

Public Destructors

[h2]~MemoryAllocator

Destructor

~MemoryAllocator()

析构函数。

Public Methods

[h2]Alloc

Method

void* Alloc(u64 size, u64 alignment = alignof(f64))

分配以alignment位数对齐的内存。

Parameters

Name

Description

size

内存大小(单位:Byte)。

alignment

alignment位数。

[h2]Flush

Method

inline void Flush()

释放内存。

[h2]Allocate

Method

template<typename T, u64 ALIGN = alignof(T), typename... ARGS> T* Allocate(ARGS&& ... args)

分配内存并初始化对象。

Parameters

Name

Description

args

初始化对象参数。

[h2]Free

Method

void Free(void* p, u64 size)

释放资源。

Parameters

Name

Description

p

资源指针。

size

资源大小。