Free dynamic memory to avoid memory leak
Dynamic memory that is allocated in the function strdup() in strdup.c is not freed when Weston is terminated by signals like SIGTERM or SIGINT. This is leading to memory leaks in Weston. In the file we can see the memory leak with it's backtrace information. I have used Valgrind tool for this. After this change, this memory leak was successfully removed. I am freeing the dynamically allocated memory inside on_term_signal() function which is the signal handler for both SIGTERM and SIGINT.
Before using this change, the leak summary of Weston was: ==1115== LEAK SUMMARY: ==1115== definitely lost: 19,963 bytes in 36 blocks ==1115== indirectly lost: 13,112 bytes in 59 blocks ==1115== possibly lost: 143 bytes in 4 blocks ==1115== still reachable: 62,427 bytes in 116 blocks ==1115== suppressed: 0 bytes in 0 blocks
After this change, the possibly lost memory leaks were completely removed and definitely lost memory leak was reduced as shown below: ==1123== LEAK SUMMARY: ==1123== definitely lost: 19,953 bytes in 35 blocks ==1123== indirectly lost: 13,112 bytes in 59 blocks ==1123== possibly lost: 0 bytes in 0 blocks ==1123== still reachable: 62,427 bytes in 116 blocks ==1123== suppressed: 0 bytes in 0 blocks