MemoryData
功能
内存管理结构体。
结构定义
struct MemoryData { enum MemoryType { MEMORY_HOST = 0, MEMORY_DEVICE, MEMORY_DVPP, MEMORY_HOST_MALLOC, MEMORY_HOST_NEW, }; MemoryData() = default; MemoryData(size_t size, MemoryType type = MEMORY_HOST, int32_t deviceId = 0) : size(size), deviceId(deviceId), type(type) {} MemoryData(void* ptrData, size_t size, MemoryType type = MEMORY_HOST, int32_t deviceId = 0) : ptrData(ptrData), size(size), deviceId(deviceId), type(type) {} void* ptrData; size_t size; int32_t deviceId; MemoryType type; APP_ERROR (*free)(void*) = nullptr; };
参数说明
参数名 |
输入/输出 |
说明 |
---|---|---|
ptrData |
输出 |
存放数据的内存地址。 |
size |
输入 |
内存大小,单位为Byte。 size值应与实际内存大小一致,否则可能导致出现coredump情况。 |
deviceId |
输入 |
设备编号。 |
type |
输入 |
申请的内存类型:
|
free |
输出 |
ptrData指针释放函数。 |
MemoryData(size_t size, MemoryType type = MEMORY_HOST, size_t deviceId = 0) |
- |
定义结构体的形式一。 |
MemoryData(void* ptrData, size_t size, MemoryType type = MEMORY_HOST, size_t deviceId = 0) |
- |
定义结构体的形式二。 |
父主题: 通用数据结构