As far as I know,In our program we always write extend function to ensure the garbage collection and avoid some hiden uncertain in ANSI C. I suggest you try to add garbage assertion in fuction free() or try to write marco and wirte a testing version of your program.that may reduce the speed of your program but it can actully clarify the problem.Bless You