Hi, I am using the nrf mem_manager library for allocationg multiple dynamic memories in my code. I have done the following
nrf_mem_init();
typedef struct
{
uint8_t b_data[31];
uint8_t id_no;
}devicetype;
devicetype * device1_database;
devicetype * device2_database;
devicetype * device3_database;
devicetype * device4_database;
nrf_free(device1_database);
if((device1_database = nrf_malloc(15)) == NULL)
printf("not alocated device1_database\n");
else
printf("success device1\n");
nrf_free(device2_database);
if((device2_database = nrf_malloc(15)) == NULL)
printf("not alocated device2_database\n");
else
printf("success device2\n");
nrf_free(device3_database);
if((device3_database = nrf_malloc(15)) == NULL)
printf("not alocated device3_database\n");
else
printf("success device3\n");
nrf_free(device4_database);
if((device4_database = nrf_malloc(15)) == NULL)
printf("not alocated device4_database\n");
else
printf("success device4\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[0].b_data[i] = RAW_device_Data[i];
}
Can anyone help me understand what is making the code to restart?