I'm reading an example of ffmpeg decoding and it has the address of a pointer being passed to a function:
static AVBufferRef *hw_device_ctx = NULL;
if ((err = av_hwdevice_ctx_create(&hw_device_ctx, type,
NULL, NULL, 0)) < 0) {
What's the point of passing the address of a pointer as an argument?
I understand that when we pass the pointer itself, if the pointer has address 0x123456
, then the function is going to be able to modify what's the object that is in this address. But when I pass the address of a pointer, I'm passing the address of where this pointer number is allocated?
If I understood right, I'm passing the address of the variable that stores 0x123456
? Why the function needs it?
Also, suppose that I want to store hw_device_ctx
in a unique_ptr
like this:
std::unique_ptr<AVBufferRed> hw_pointer;
How can I pass it to av_hwdevice_ctx_create
? Because I get an error when I do
av_hwdevice_ctx_create(&hw_pointer.get(),...
It says:
expression must be an lvalue or a function designator