I am trying to use mmap
for mapping and sharing data between processes on my device. My target is an embedded device running Embedded Linux
My processes are implemented using C++, and using containers such as std::list
and std::map
. Obviously the size of the containers are changing as the program runs.
If I use a structure to be shared between processes as below for example :
struct MYSTRUCT
{
int val1;
int val2;
list <int> list1;
};
MYSTRUCT myStruct;
// later as the program runs for example...
myStruct.list1.push_back(100);
I would then like to map this using mmap
. The API for mmap is as follows :
void *mmap(void *addr, size_t length, int prot, int flags,int fd, off_t offset);
For the length
parameter, can I use sizeof(myStruct) + myStruct.list1.size()
for example ?