implemented malloc and free