Hi John, On 28 June 2016 at 09:23, John Zhang <john.zh...@anu.edu.au> wrote: > I have another question regarding passing an array value to C function using > RFFI. > Suppose I have a function in C that’s like this: > void fn(void** array_of_voips, int length) > How do I in RPython call the function using RFFI passing an array value for > it? > it seems that I can’t just do > fn([a, b, c], 3)
Indeed, this works in CFFI, but RFFI is by far not as nice as that. You need to build the array value manually with "ar=lltype.new(ARRAY_OF_VOIDP.TO, length, flavor='raw'); ar[0]=a; " etc., remembering to do "lltype.free(ar, flavor='raw')" at the end. Or use "with lltype.scoped_alloc(...)", which replaces both the malloc at the start and the free at the end. A bientôt, Armin. _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev