unreferencing pointers

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Tue Dec 17 10:31:47 UTC 2019


On 17/12/2019 08:32, Ty Young wrote:
> Hi,
>
>
> Thanks to the LLVM 9 commit I've been able to create bindings for 
> jextract. Problem is that the libusb API utilizes "unreference" 
> variables to store the list of USB devices at it's entry pointer.
>
>
> From the "In a nutshell..." section:
>
>
> libusb_device **list;
>
> libusb_device *found = NULL;
>
> ssize_t cnt = libusb_get_device_list(NULL, &list);
>
>
> ...which -unless I'm missing something- doesn't work in Java since 
> variables have to be declared as *something* and declaring it as null 
> hits an internal NullPointerException check.
>
>
> Is this an unsupported edge case or am I missing something?

What is the Java code that corresponds to this? The one you are playing 
with. Is 'list' the variable you'd like to start off with null? Note 
that that is not really what C does - when C sees a blank declaration 
like that it would still allocate the space to hold a pointer - so you 
must allocate, even if you don't see the allocation in the corresponding 
C code.

Maurizio

>
>
> Thanks.
>


More information about the panama-dev mailing list