[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Preallocating lua string before pushing them on the stack (prevent double alloc / memcpy)
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Mon, 16 Aug 2010 11:20:22 -0300
> char *luaL_prepstring (lua_State *L, size_t len);
> void lua_pushprepstring (lua_State *L, char *prepstring);
On occasion I have used lua_newuserdata as your luaL_prepstring and then
lua_pushstring as your lua_pushprepstring. This does involve double allocation
and copy but at least the boring parts (allocation and deallocation when an
error occurs) are handled by Lua.