Bugfix; compare numbers, not function pointers...
Added <stdlib.h> for malloc/free