Hi, I am using the nrf mem_manager library for allocationg multiple dynamic memories in my code. I have done the following
devicetype * device1_database;
devicetype * device2_database;
devicetype * device3_database;
devicetype * device4_database;
if((device1_database = nrf_malloc(15)) == NULL)
printf("not alocated device1_database\n");
if((device2_database = nrf_malloc(15)) == NULL)
printf("not alocated device2_database\n");
if((device3_database = nrf_malloc(15)) == NULL)
printf("not alocated device3_database\n");
if((device4_database = nrf_malloc(15)) == NULL)
printf("not alocated device4_database\n");
All the devices are getting the allocation for the memory as I am getting success prints ... But while filling the data to these values , the first two dynamically allocated memories (i.e. device1_database,device2_database )get filled with proper data and while filling the third allocated memory (i.e. device3_database) the code restarts . The code snippet of filling the data is shown below:
for(int i = 0; i < 15;i++)
device1_database.b_data[i] = RAW_device_Data[i];
Can anyone help me understand what is making the code to restart?
Are you able to check the memory addresses written to the 4 devicetype pointers after you have run the calls to nrf_malloc(..) ?
If the code crashes when you try to write to one of the pointers it indicates that it has an invalid memory address.
Are you running the code on a standard nRF52DK?