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

  • From: Johnson Lin <arch.jslin@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Fri, 20 Jul 2012 14:07:21 +0800

2012/7/20 Robert G. Jakabosky <bobby@xxxxxxxxxxxxxxx>:
> 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.
> --
> Robert G. Jakabosky

Thank you again (and William also for all the discussions and suggestions)

Funny thing is, to fix this obj-to-callback mapping problem, I re-read
ffi_semantics page on a few times, but somehow I just
skipped one very important paragraph, wrt "cdata as table keys."

I think that paragraph explained everything. And I also think
tonumber() is more suitable for me to go. William formatted it to
strings, but as Robert pointed out that didn't help with precision
probably, since it also contained a step of tonumber(). (If I
understand it correctly)

One thing I also tried just a while ago is just tostring(cdata), and
it worked too. Somehow I think if I want to support 64bit FULLY, it
might be faster if I just tostring(cdata) as a whole, and not
converting pieces of addresses and concat them or aggregate arbitrary
fields of the cdata to a string.

About specialize a hash function myself.... I am not sure if it is
beneficial in this case. Provide my poor programming skill, it
probably won't turn out to be a good hash function anyway.


Other related posts: