/*
 * Copyright 2019 Unisound AI Technology Co., Ltd.
 * Author: Hao Peng
 * All Rights Reserved.
 */

#ifndef OSAL_OSAL_MEMORY_POOL_H_
#define OSAL_OSAL_MEMORY_POOL_H_

#include "osal/osal-types.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef void* OsalMemoryPoolHandle;

/*
 * @Description: 创建内存池
 * @Input params: size: 内存池大小，含内存池管理节点开销
 * @Output params:
 * @Return: 内存池 handle
 */
OsalMemoryPoolHandle OsalMemoryPoolCreate(size_t size);

/*
 * @Description: 分配内存
 * @Input params: handle: 内存池 handle
 *                size: 大小，超出内存池可用内存大小时会分配新内存
 * @Output params:
 * @Return: 内存地址
 */
void* OsalMemoryPoolAlloc(OsalMemoryPoolHandle handle, size_t size);

/*
 * @Description: 释放内存
 * @Input params: handle: 内存池 handle
 *                ptr: 内存地址
 * @Output params:
 * @Return:
 */
void OsalMemoryPoolDealloc(OsalMemoryPoolHandle handle, void* ptr);

/*
 * @Description: 内存池销毁
 * @Input params: handle: 内存池 handle
 * @Output params:
 * @Return:
 */
void OsalMemoryPoolDestroy(OsalMemoryPoolHandle handle);

/*
 * @Description: 打印内存池使用情况
 * @Input params: handle: 内存池 handle
 * @Output params:
 * @Return:
 */
void OsalMemoryPoolStatus(OsalMemoryPoolHandle handle);

#ifdef __cplusplus
}
#endif

#endif  // OSAL_OSAL_MEMORY_POOL_H_
