To use free you should include stdlib.h rather than malloc.h according to man page...