C/C++ Fixing the Size of a Map in Shared Memory

  • Thread starter Thread starter FrostScYthe
  • Start date Start date
  • Tags Tags
    Map Memory
AI Thread Summary
To create a fixed-size map in C++, the standard map data structure does not support this directly, as it dynamically allocates memory and does not guarantee contiguous storage. For shared memory usage, a fixed-size array or a different data structure, like a fixed-size hash table, may be more appropriate. The discussion highlights that even if a map were fixed-size, sharing it in shared memory could be problematic due to its potential non-contiguous memory allocation. Alternative approaches for inter-process communication without shared memory are also suggested, emphasizing the need for a suitable data structure for shared access.
FrostScYthe
Messages
80
Reaction score
0
Hi, I'm wondering how to give a map a fixed size like you can give an array a fixed size by just "byte data[SIZE*DATASIZE]".. or if it's possible anybody know..

struct Table {
map<int, int> table; //
};

struct Table *flightChart;

The reason I have to give this a fixed size, is becuase I have to map this in shared memory :\, so that another process may access it, or is it possible to pass this structure to another process without shared memory :\
 
Technology news on Phys.org
Even if it were fixed size, sharing your map object in shared memory might not accomplish what you want to do anyway. There's no guarantee that the map object store its data within a single contiguous block of memory -- it may store data in blocks all over the heap.

- Warren
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...
Back
Top