Posted March 10, 200916 yr How do you edit "malloc" to alloc shared memory?Am I going to have to dig the source out of the cpp file and redefine it?
March 10, 200916 yr how about: #undef malloc#define malloc(size) supersharedalloc(size)void * supersharedalloc(size){... do whatever it takes to allocate shared memory here...return newptr;} Or you could try overloading new and delete, that's safer + you can just define malloc as new and free as delete and you covered both...
March 10, 200916 yr Author Actually don't really need to do this. Boost::Interprocess is what I need .
March 10, 200916 yr Author Also found this project.http://allocator.sourceforge.net/Not to sure on which I am going to use. From the looks of it, boost requires that you provide it a size. Which I want a dynamic allocator.Really what I want to do is something like.#pragma comment(linker, "/SECTION:.shared,RWS")#pragma data_seg(".shared")std::vector<int, somesharedallocator> * SharedVector;#pragma data_seg()int Main(){ if (SharedVector == NULL) //Did an instance of the dll already create the vector? SharedVector = new std::vector<int, somesharedallocator>();}
March 11, 200916 yr This would be the STL specific approach:http://www.codeguru.com/cpp/cpp/cpp_mfc/st...ticle.php/c4079Not sure if you need a generic allocation version, but usually the STL comes in a library so overloading new and delete will not affect the allocator.
Create an account or sign in to comment