Reputation: 223
I have no problems implementing the memory mapped file. The question is. Assuming this returns a valid memory view.
void* pBuf = MapViewOfFile(hMapFile,
FILE_MAP_WRITE,
0,
0,
0);
Do i have alternatives to using memcpy to give data to it? for instance can i tell my application to store data in it? I really want something like char* buffer = new char[1073741824] where the new places the data in the memory mapped file. this seems logical. or will i have to write a wrapper that writes to the memory view using memcpy? that would be disapointing.
Upvotes: 2
Views: 2488
Reputation:
You can use the placement new operator or you can cast the address to a structure or class you want to use. The advantage of placement new is that the constructor of the class will be called. If you use from then on that pointer you don't need to copy the data but read and write directly to it.
Upvotes: 0
Reputation: 612784
Probably the easiest approach is to use the boost memory mapped file classes which give the additional benefit of being portable.
Upvotes: 3