[C] 纯文本查看 复制代码 #include "stdio.h"
/* USER CODE END 0 */
void **argv = NULL;
uint32_t argc = 0;
uint8_t bufx[50] = {0,1,2,3};
uint8_t bufx1[50];
uint8_t bufx2[50];
uint8_t bufx3[50];
uint8_t *tempbuf = NULL;
void add_buffer_to_argv(uint32_t *index, uint8_t *buffer)
{
*index = *index + 1;
argv = realloc(argv,sizeof(*argv) * (*index));
if (argv == NULL) {
//your error check
}
argv[*index-1] = buffer;
}
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
add_buffer_to_argv(&argc,bufx);
add_buffer_to_argv(&argc,bufx1);
add_buffer_to_argv(&argc,bufx2);
add_buffer_to_argv(&argc,bufx3);
for (uint32_t i = 0; i < argc; i ++) {
tempbuf = argv[i];
}
} |