Re: opaque pointers and metatype

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

A real example:

   typedef struct pthread_mutex_t_* pthread_mutex_t;
   int pthread_mutex_init (pthread_mutex_t * mutex, const
pthread_mutexattr_t * attr);
   int pthread_mutex_destroy (pthread_mutex_t * mutex);

In C, you'd say:

   pthread_mutex_t m;
   pthread_mutex_init(&m, 0);
   pthread_mutex_destroy(&m);

In Lua you want to say:

   m = new_mutex()
   m:destroy()

Hopefully with a minimum of wrappings and allocations.

Other related posts: