RE: [suse-programming-e] False memleak detected?
Verdi March wrote on Monday, June 19, 2006 12:55 PM::
The reason you're getting the report is because ilist is local to main(). After leaving main() which is where valgrind does its leakage tests, there is no longer a list, so there can be no references to the allocated nodes. If you make ilist global, valgrind is silent. Believe valgrind - it is wiser than mere humans! There IS a very real leak that your example doesn't reveal:
If you try to insert a node that is already in the list, "is" is not linked into the list, and the caller (i.e. insert) has already relinquished control so has no way of releasing the node. You would be better off changing the code so that the calloc is only performed once you've identified the need to insert the node (i.e. after the for-loop in insertion_sort()) Phil -- ********************************************************************** This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the H.E Information Systems Ltd. Tel: 0161 866 9066 Web: www.heis.co.uk This footnote also confirms that this email message has been swept by MIMEsweeper for the presence of computer viruses. www.clearswift.com **********************************************************************
participants (2)
-
Phil Betts
-
Verdi March