esp32 resets after memory allocation failed by asprintf
Posted: Fri Oct 19, 2018 8:12 pm
Hi,
I want to use asprintf for getting large string and dynamic allocation, but when i am using in my task, memory allocation gets failed.
and esp32 resets. what is wrong in my code?
I want to use asprintf for getting large string and dynamic allocation, but when i am using in my task, memory allocation gets failed.
and esp32 resets. what is wrong in my code?
Code: Select all
void producer_task(void *pvParameter){
char *mydata=NULL;
while(1){
vTaskDelay(10);
int ret=asprintf(&mydata,"abcdefghijklmnopqrstuvwxyzxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
if(ret==-1)
{
ESP_LOGI(tag, "asprintf:memory allocation failed");
}
ESP_LOGI(tag, "single_tag:%s", mydata);
if(xQueueSend( xQueue, ( void * )&mydata, ( portTickType )0 )==errQUEUE_FULL)
{
ESP_LOGI("Queue","Queue is full..");
}
mydata=NULL;
free(mydata);
}
}