MemoryData
Description
Defines the structure for memory management.
Structure Definition
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 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 = nullptr; size_t size; int32_t deviceId; MemoryType type; APP_ERROR (*free)(void*) = nullptr; }; |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
ptrData |
Output |
Address of the memory for storing data |
size |
Input |
Memory size, in bytes. The size must be the same as the actual memory size. Otherwise, a core dump may occur. |
deviceId |
Input |
Device ID |
type |
Input |
Type of the allocated memory:
|
free |
Output |
ptrData pointer release function |
MemoryData(size_t size, MemoryType type = MEMORY_HOST, int32_t deviceId = 0) |
- |
The first form for defining a structure |
MemoryData(void* ptrData, size_t size, MemoryType type = MEMORY_HOST, int32_t deviceId = 0) |
- |
The second form for defining a structure |
Parent topic: General Data Structures