Skip to content

katlogic/pudata

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
lua_pushuserdata() polyfill

Sometimes, one needs to push existing userdata by pointer. This is not
safe (as the pointer might be stale), therefore it is not part of core
Lua api.

This header file should be included after Lua headers - mainly because
it overrides lua_newuserdata() with a macro, all hell would break loose
otherwise.

After that, you can push userdata by pointer. In case the userdata
object has been collected in the meantime, nil is pushed on stack.

This is handy for debugging, with native function you'd get dangling
pointer on Lua heap. It is also very slow, so it is not a good idea
to use this in release / performance bound code.

Patching Lua(JIT) with native function is left as an excercise for the reader.

-- k

About

lua_pushuserdata() polyfill

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages