lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:
> 
> >Are we going to document lua_boxpointer?
> 
> In Lua 5.0 we cleaned up the confusion of what a userdata is and how it is
> created: userdata are Lua objects created with lua_newuserdata:
> 
>         LUA_API void *lua_newuserdata (lua_State *L, size_t size);
> 
> lua_newuserdata creates an object that has an attached buffer of the given
> size; this buffer is returned to the host program and can be written to.
> Lua never looks inside the buffer, but userdata objects, like all other objects,
> are subject to garbage collection. In other words, lua_newuserdata gives
> you a buffer that you don't have to worry about mallocing or freeing, but
> which you can used to store whatever you want, even dynamically changing its
> contents.

That's good! But, what if you want to resize the data block pointed to?
Wouldn't a void * lua_resizeuserdata(lua_State *L, void *ptr, size_t
size)
come in handy then? Or is it already there?

-- 
"No one knows true heroes, for they speak not of their greatness." -- 
Daniel Remar.
Björn De Meyer 
bjorn.demeyer@pandora.be