There is a function with a header such as this:
BPS_API int dialog_event_get_filebrowse_filepaths(bps_event_t* event,
char** file_paths[], int* num_paths);
This is from BlackBerry 10’s Native SDK for anyone wondering (it can be found here).
The question is: what am I supposed to provide as the second argument. This function should populate an array of char pointers in order to return the file paths selected.
I tried to call it this way:
char* ar[2];
dialog_event_get_filebrowse_filepaths(event, &ar, &number_paths);
And I am getting an error from QNX Momentics as such:
cannot convert 'char * (*)[2]' to char * * * for argument 2 to int
dialog_event_get_filebrowse_filepaths(bps_event_t *, char * * *, int *)
This seems the most logical way to call it. It needs the memory address of an array of pointer in order to set them, as far as I understand.
However, if I declare:
char** ar[2];
dialog_event_get_filebrowse_filepaths(event, ar, &number_paths);
It works, but this way I created an array of pointers to char pointers (an array of arrays of char*). Is this what I should really provide to the function?
The documentation really should have been more explicit, but I’m pretty sure this is what the function expects:
First, a few rules of thumb to help decode the function:
char***. This means we have to find a meaning for three pointers.char*(leaving out theconstfor brevity). As we expect the function to populate an array of strings, that’s one*accounted for.*.*. This also explains the documentation note thatThe memory holding these values must be freed using bps_free() when no longer needed— because the memory was allocated by the library function, rather than by you, it is important that you use the correctfreefunction.So, the function should be called like this:
When the function returns,
strswill point to the first entry of an array of strings allocated bydialog_event_get_filebrowse_filepaths.