Re: Making FFI callbacks call free() automatically when it's collected

  • From: Mike Pall <mike-1207@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 20 Jul 2012 13:22:27 +0200

Robert G. Jakabosky wrote:
> I would use a cast to uintptr_t instead of int to support 64bit pointers.  
> uintptr_t is guaranteed to be the same size as a pointer.

Use intptr_t if you plan to pass it to tonumber().

Conversions between *unsigned* integers and FP numbers are rather
expensive on some platforms. Most CPUs only support conversions of
*signed* integers to/from FP numbers.

Anyway, the only supported 64 bit platform is x64 (and only if it
uses the lower 47 bits of the address space for user mode). I.e.
all 64 bit pointer values are non-negative and the 47 significant
bits fit into the mantissa of a double.

Do NOT use tostring() to get unique keys for simple scalar cdata
objects (it's not JIT-compiled, too).


Other related posts: