[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: Cuero Bugot <cbugot@...>
- Date: Mon, 16 Aug 2010 08:01:29 -0700
> lua_pushlstring does almost what you want. Couldn't there be just one
> new function, lua_allocstring, that works like lua_pushlstring but
> returns a char* rather than taking one, so you can then write into the
> buffer it allocated?
You cannot have one function (lua_allocstring), because when you 'add' a string in the Lua VM it does a hash and keep it unique, etc. So if you want to add a string in the Lua VM you need to have its content.
That is why my idea of proposal was to dissociate the allocation part (prepstring) from the addition to the LuaVM part (push prepstring)