working malloc and free