implements malloc and free