Good afternoon,
First, I apologize if I'm asking something obvious or outside the acceptable topics. I'm starting to use Boost so I'm quite newbie.
I'm interested in using the managed_external_buffer in order to perform buffer copies into a created buffer that was created previously. Therefore, I will be storing mostly raw data into that buffer.
Basically, I'm trying to do the following:
Suppose a program uses the following int array:
int numbers[10] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
Eventually, I have to copy a chunk of that array into a pre-allocated buffer (i.e. the managed_external_buffer). Let the chunk be defined with:
typedef struct {
void* addr;
size_t size;
} chunk_t;
However, these chunks can overlap, so I will sometimes merge two overlapping chunks into a bigger one. Example:
// Chunk 1
chunk1_addr = (void*)&numbers[3];
chunk1_size = 3 * sizeof(int);
// Chunk 2
chunk2_addr = (void*) &numbers[4];
chunk2_size = 4 * sizeof(int);
The desired result is a single chunk containing {3, 4, 5, 6, 7}.
The proposed problem is the merge, but how to find those chunks in the managed_external_buffer, so my question is the following:
- Would it be possible to use named objects with another data type other than CharType and use managed_external_buffer::find to look for them? The thing is I could generate a hash or a numerical ID to identify the chunk. Generating a string using that number could be done but it would not be efficient.
Otherwise, I guess I would have to keep a map (or other collection) with the <chunk ID, chunk pointer> pairs, define the managed_external_buffer with boost::interprocess::null_index (since I won't be using named objects) and use it through allocate and deallocate. Is this correct?
Thanks in advance,
Jorge