Original Post
So I was looking for a way to "map" a std::istream to a memory-mapped file (without copying the memory) when I came across this post:
http://www.gamedev.net/community/forums/viewreply.asp?ID=3521298
I said to myself, "alright that doesn't sound too bad" and whipped this up:
So firstly, what am I doing incorrectly to trigger this crash (because I honestly have no idea how to use a strstreambuf)? And secondly, is there some sort of an "istrstreambuf" that I could use so I wouldn't have to cast away the const in the filedata buffer?
http://www.gamedev.net/community/forums/viewreply.asp?ID=3521298
I said to myself, "alright that doesn't sound too bad" and whipped this up:
std::strstreambuf buffer;buffer.pubsetbuf( (char*)descrip.filedata, descrip.filesize);std::istream is(&buffer);// pass is to a library function hereI have two problems with this code, one is that I don't like casting descrip.filedata from a (const unsigned char*) to a (char*). The other problem I have is that the code crashes within the library function call that takes is as a parameter.So firstly, what am I doing incorrectly to trigger this crash (because I honestly have no idea how to use a strstreambuf)? And secondly, is there some sort of an "istrstreambuf" that I could use so I wouldn't have to cast away the const in the filedata buffer?