You mix up some terminology. You aren't passing arrays you are passing reference to your allocated data. Arrays need to be fixed in size so you won't be able to dynamically allocate them (Edit: with that I mean you cant allocate them on the stack without knowing the size by compile time). An easier way here would be to change the signature of the function to accept a pointer
void someFunction(uint8_t *array) { /* ... */ }
and then pass the pointer by value
someFunction(array);
I also advise you to use the new
and delete[]
operators designed for allocating such data in C++, but it's not necessary for this question.
Edit:
Of course, a safer way is to use the std::vector
class for dynamic-length data and std::array
class for static-length data.