I have a std::vector which will be filled with instructions for some proprietary hardware. I have code to construct this buffer and manipulate it just fine.
The problem is I need to make use of another library (C based) which builds similar proprietary hardware instructions, but the library expects us to make raw memory available and return a pointer to it, which the library then uses to write its commands.
I would like to accomplish something like the following [pseudo code, nothing like the real code]:
void* theLibraryCallback (void* clientData, unsigned int theLibrarySize)
{
std::vector<unsigned int> cmd = reinterpret_cast<std::vector<unsigned int>>(clientData);
std::vector<unsigned int>::size_type cmdSize = cmd->size();
for (int loop=0;loop<theLibrarySize; loop++)
cmd->push_back(0xdeadbeef);
return cmd->GET_RAW_POINTER_AT(sizeof(unsigned int)*cmdSize); ///<< How can I do this?
}
The concept is that I add values to the vector to make space, but the other library modifies them directly.
If I cannot do this ill have to consider allocating temporary raw memory, filling this out with the library and then copying it into my vector, but would like to avoid this if possible.
Is what I want to do possible somehow?