The CFile-derived class that supports memory files.
These memory files behave like disk files except that the file is stored in RAM rather than on disk. A memory file is useful for fast temporary storage or for transferring raw bytes or serialized objects between independent processes.
CMemFile objects can automatically allocate their own memory or you can attach your own memory block to the CMemFile object by calling Attach. In either case, memory for growing the memory file automatically is allocated in nGrowBytes-sized increments if nGrowBytes is not zero.
The memory block will automatically be deleted upon destruction of the CMemFile object if the memory was originally allocated by the CMemFile object; otherwise, you are responsible for deallocating the memory you attached to the object.
You can access the memory block through the pointer supplied when you detach it from the CMemFile object by calling Detach.
The most common use of CMemFile is to create a CMemFile object and use it by calling CFile member functions. Note that creating a CMemFile automatically opens it: you do not call CFile::Open, which is only used for disk files. Because CMemFile doesn't use a disk file, the data member CFile::m_hFile is not used and has no meaning.
CMemFile uses the run-time library functions malloc, realloc, and free to allocate, reallocate, and deallocate memory; and the intrinsic memcpy to block copy memory when reading and writing. If you'd like to change this behavior or the behavior when CMemFile grows a file, derive your own class from CMemFile and override the appropriate functions.