> > You did not say how long you need the memory: If you need automatic > > deallocation when the caller of f returns, you can return an auto_ptr > > from f. > > How does it know when to deallocate the memory? The destructor deallocates the memory.