ffi type of pointer to

  • From: Justin Cormack <justin@xxxxxxxxxxxxxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 12 Jun 2012 09:20:29 +0100

Would it be possible to add an ffi function that takes a ctype and returns
the ctype of a pointer to that type? (ffi.ptrtype(ct) or something?

I seem to have a lot of code that needs to cast bits of memory returned
from ffi C functions to different types, but if you store types as ctypes
you then need to define another type for the pointer to the type. It makes
library functions that need both the type and a pointer to it messy, or
they need to take the string type and append a '*'. It would clean up a lot
of code.

eg you get or want to create an array of a given type, so you need both the
size and a pointer to the type for the cast.

Justin

Other related posts: