Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

C++ edit malloc for shared memory?

Featured Replies

Posted

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?

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

  • Author

Actually don't really need to do this.

Boost::Interprocess is what I need :D .

  • 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>();
}

This would be the STL specific approach:

http://www.codeguru.com/cpp/cpp/cpp_mfc/st...ticle.php/c4079

Not 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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.