Usually in an API like that the C function will be allocating the array, so you shouldn’t be passing a reference to an existing Julia vector. Instead, you would do something like:
data_ptr = Ref{Ptr{UInt8}}()
data_length = Ref{Csize_t}()
@ccall somelibrary.somefunction(data_ptr::Ref{Ptr{UInt8}}, data_length::Ref{Csize_t})::Cvoid # if it returns void
data = unsafe_wrap(Array, data_ptr[], data_length[], owns=true)
where passing owns=true assumes that Julia is supposed to call free on the resulting array when it is done with it (otherwise you could make a copy, as in your other thread: Does `String(unsafe_wrap(cstring, len, own=true))` free the memory it points to?)