Re: binding a C functions that allocates two chunks of memory and returns an integer
Posted by a001 on Dec 02, 2011; 11:01am
URL: https://forum.jogamp.org/binding-a-C-functions-that-allocates-two-chunks-of-memory-and-returns-an-integer-tp3547863p3554331.html
Sven, thank you very much. Your detailed answer was very useful.
There is still one more question, if you may.
I've mapped the foo_t to long, with Opaque long foo_t.
Now, GlueGen provides:
public int foo(PointerBuffer arg1, PointerBuffer arg2)
as the interface to:
int foo(foo_t **a, foo_t **b);
What if I need to pass a (foo_t *) written by foo() to another API, say bar()?
int bar(foo_t *a, int c);
Here, keeping foo_t opaque with long, a LongBuffer would be generated to the pointer to foo_t:
public int bar(LongBuffer arg1, int arg1)
Looking at the PointerBuffer documentation, I've noticed the getBuffer() method, that could be used to return a ByteBuffer. In turn, a view of the ByteBuffer as LongBuffer can be created using the asLongBuffer() method.
Is there a better method to pass the PointerBuffer written by foo() as a LongBuffer to bar()?
Thank you very much.
Cheers,
a.