proper way of checking cdata pointer based on http://wiki.luajit.org/ffi-knowledge