lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>The only downside now to this approach is the code
>pushing user data becomes more complex in EVERY part of the application,
>if you don't want memory allocated every time.

Then define lua_pushuserdata to use the registry to store the Lua values
created by lua_newuserdatabox, using the C pointer as an index. When the pointer
exists in the registry (or any other table), simply return the value.

Since lua_pushuserdata is no longer part of the API, you can simply add a
function lua_pushuserdata that does the above and not change the code at all.
--lhf