Implement no copy memory
Florian Weimer
fweimer at redhat.com
Tue May 21 08:49:16 UTC 2019
* Maurizio Cimadamore:
> On 21/05/2019 05:26, Ardika Rommy Sanjaya wrote:
>> If using panama should I cast the Pointer<Byte> before get the
>> content data?
>
> In Panama you would do this:
>
> Pointer<Byte> buf = ...
>
> Pointer<Short> ps = buf.cast(NativeTypes.VOID).cast(NativeTypes.UINT16);
> short s = ps.get();
>
> or...
>
> Pointer<Integer> pi = buf.cast(NativeTypes.VOID).cast(NativeTypes.UINT32);
> int i = pi.get();
>
> Note that you have to cast through VOID first, otherwise the Panama
> runtime will complain about incompatible cast.
Wouldn't it make sense for packet parsing to construct a ByteBuffer
first, and do the parsing using that?
Thanks,
Florian
More information about the panama-dev
mailing list