This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

VLIB中malloc动态分配内存失败



在DSP中使用VLIB的函数,参数需要动态分配内存,如果分配的空间多了就会失败,例如使用

void VLIB_Canny_Edge_Detection(const uint8_t *pInput,
int16_t *pBufGradX,
int16_t *pBufGradY,
int16_t *pBufMag,
uint8_t *pBufOut,
uint8_t *pScratch,
int32_t *numItems,
uint16_t width,
uint16_t height);

demo里面会给前面7个参数动态分配陪空间,

/* Allocate buffers for each test vector */
uint8_t *pInput = (uint8_t *) VLIB_malloc(bufferSize * sizeof(uint8_t));
int16_t *pBufGradX = (int16_t *) VLIB_malloc(bufferSize * sizeof(int16_t));
int16_t *pBufGradY = (int16_t *) VLIB_malloc(bufferSize * sizeof(int16_t));
int16_t *pBufMag = (int16_t *) VLIB_malloc(bufferSize * sizeof(int16_t));
uint8_t *pScratch = (uint8_t *) VLIB_malloc(bufferSize * sizeof(uint8_t));
uint8_t *pBufOut = (uint8_t *) VLIB_malloc(bufferSize * sizeof(uint8_t));
uint8_t *pBufOut_cn = (uint8_t *) malloc(bufferSize * sizeof(uint8_t));

如果我输入的一帧图像数据稍大一点会出现malloc失败(demo中的测试数据比较小,实际我用的数据相对比较大最少720P)