Re: opaque pointers and metatype

  • From: Cosmin Apreutesei <cosmin.apreutesei@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Tue, 4 Mar 2014 04:01:28 +0200

> I don't think it can be done as long as you're missing the size.

I'm not missing the size, pthread_mutex_t is a pointer and it's size
is sizeof(pthread_mutex_t), i.e. sizeof(void*).

> Obviously the key difference is that the library itself has allocates
> storage.

Here too, the library allocates storage. It's just a difference in
style. Some APIs return an opaque* while others _take_ and opaque**
(two-stars), or an &opaque*, which is the same thing, and fill that
out.

> allocation. In this case`pthread_mutex_init` just initializes and
> assumes it has a big enough blob of memory.

pthread_mutex_init() assumes it has an address location to write to
and nothing more.

Other related posts: