lua-users home
lua-l archive

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


I'm trying to figure out how to use lua_pushlightuserdata.  I have a function

put_data_in_lua(lua_State *L, void *mem)
{
    // want get the mem into Lua
    // how do I get it into a lua variable?
    lua_puslightuserdata(L, mem);   //is this right?  how do assign
it to a variable?
}


static int process_data(lua_Stat *L)
{
     //get user data and do something with it
}

static const struct luaL_Reg mylib [] = {
   {"process", process_data},
   {NULL, NULL}
};

extern int luaopen_mylib{lua_Stat *L)
{
    luaL_register(L, "mylib", mylib);
    return 1;
}

/***********************
Lua Script
*/

memory = nil

function setmem(mem)
   memory = mem
end

function process_memory
   memory.process()
end

thanks,
wes