I've been working on this program for five months now. Its a real time application of a sensor network. I create several linked lists during the life of the program and Im using malloc for creating a new node in the link. What happens is that the program suddenly stops or goes crazy and restarts. Im using AVR and the microcontroller is ATMEGA 1281. After a lot of debugging I figured out that that the malloc is causing the problem. I do not free the memory after exiting the function that creates a new link so Im guessing that this is eventually causing the heap memory to overflow or something like that. Now if I use the free() function to deallocate the memory at the end of the function using malloc, the program just gets stuck when the control reaches free(). Is this because the memory becomes too clustered after calling free() ?
I also create reference tables for example if 'head' is a new link list and I create another list called current and make it equal to head.
table *head;
table *current = head;
After the end of the function if I use free
free(current);
current = NULL:
Then the program gets stuck here.
I dont know what to do. What am I doing wrong? Is there a way to increase the size of the heap memory?