For api test: use malloc and free