类别:Allocator
记忆体配置统一管理
类型 | 使用 | 成员 | 说明 |
建构子 | public | ||
解构子 | public | ||
函式 | public | 配置记忆体。 | |
函式 | public | 释放记忆体。 | |
函式 | public | 记忆体配置区块数量。 |
建议
所有CIOS Audio Core内部的程序,都被建议使用Allocator来配置及释放记忆体。外部程序不应使用这个类别,这是专门为了「音讯驱动介面」内部使用的类别。C/C++定义
class Allocator
{
public:
explicit Allocator (void) ;
virtual ~Allocator (void) ;
static void * allocate (long size) ;
static void free (void * block) ;
static int blocks (void) ;
};
示范
配置1024位元的记忆体。
char * buffer ;
buffer = (char *)Allocator::allocate(1024) ;
释放记忆体。
Allocator::free(buffer) ;
如果buffer本身即为NULL,则不会释放任何记忆体,外部程序无需自行检查是否为NULL。