I moved my code to use std::vector instead of char *mem = malloc(...) but now I am facing a problem that I can only access the vector d
std::vector
char *mem = malloc(...)
You can write that code perfectly legally. All you need to do is alter fill_data to take a std::vector&. Of course, if this is an external C API, then you don't have much choice in the matter.
std::vector&