Malloc and Free
- Allocate memory aligned to a specified byte:
void* HMPP_Malloc(int32_t len);
- Release memory:
void HMPP_Free(void* ptr);
Parameters
Parameter |
Description |
Value Range |
Input/Output |
|---|---|---|---|
len |
Byte length (HMPP_Malloc function) Array length (HMPPS_Malloc_xxx function) |
> 0 |
Input |
ptr |
Pointer to the memory block to be released (Free function) |
The value cannot be NULL. |
Input |
width |
HMPPI_Malloc_xxx_kk (kk can be C1, C2, C3, C4, or AC4, indicating the channel status) considers the allocated continuous memory as a two-dimensional matrix (width x height). width indicates the number of elements in each row. |
> 0 |
Input |
height |
Number of rows in the two-dimensional matrix of HMPPI_Malloc_xxx_kk |
> 0 |
Input |
step |
HMPPI_Malloc_xxx_kk fills the number of bytes in a line to an integral multiple of 64 and returns the value in the address specified by step. |
The value cannot be NULL. |
Output |
Return Value
HMPP_Malloc function:
- Success: The start pointer to the allocated memory is returned.
- Failure: NULL
Error Codes
None
Note
The input parameter of the Free function must be the return value of the Malloc function.
Example
#define BUFFER_SIZE 100
void Malloc_Free_Example() {
void *ptr = HMPP_Malloc(BUFFER_SIZE);
HMPP_Free(ptr);
uint8_t *ptrs = HMPPS_Malloc_8u(BUFFER_SIZE);
HMPPS_Free(ptrs);
int32_t step;
uint8_t *ptri = HMPPI_Malloc_8u_C1(BUFFER_SIZE, 4, &step);
printf("%d\n", step);
HMPPI_Free(ptri);
}
Output:
128