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
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top