On Sun, 17 May 2009 13:41:59 -0400
Timothy Wall <twal...@dev.java.net> wrote:
On May 17, 2009, at 1:33 PM, Zsolt Kúti wrote:
The counterpart of an array of pointers what I need, I just
uncertain how to approach that.
The API doc says on Structure:
When used as a function parameter or return value, this class
corresponds to struct*.
So I tried passing a variable of my Structure and using its
toArray() method with the size that was given back via an
IntByReference by the function. This does not seem to work either.
Just to be clear here is the defining C code:
struct my_struct
int f(struct my_struct *s, int *i)
In usage it looks:
static struct my_struct my_s
static unsigned int my_i
(call) f(&my_s, &my_i)
(use) my_s[0]
How does the native code know how many structures it can fill in?
Presumably the "int *" will be filled in with the number of elements
available, but you need that number before you call the function.
I guess this must be a usual idom in C for a dynamic array.
The function uses the passed address to struct to start filling it and
keep incrementing address while there are new data, counting them in a
counter (my_i in this case).
Structure and Structure[] will pass the same address to the native
code; the latter will point to a larger block of memory if the array
size is greater than one.
What exactly isn't working?
There is no data in the struct, while my_i shows there must be one
struct filled. The C code does work (as shown by a program that uses
the same function).
Zsolt