Jump to content
Tuts 4 You

C++ edit malloc for shared memory?


Recommended Posts

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...

Link to comment

Also found this project.


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>();
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...