lua-users home
lua-l archive

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


>That's good! But, what if you want to resize the data block pointed to?

You'll have to manage it yourself: create a new userdata and copy the old
contents to the new buffer.

>Wouldn't a void * lua_resizeuserdata(lua_State *L, void *ptr, size_t size)
>come in handy then?

Perhaps, but it would have to be "int index" instead of "void *ptr", that is,
it would to receive a Lua object to resize, not a pointer. The pointer is
returned by lua_newuserdata just so you can fill the buffer, but the main
value is the whole userdata value that lua_newuserdata also leaves on the stack.
--lhf