check calloc return and remove useless null checks before free