lua-users home
lua-l archive

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


On Mon, Aug 16, 2010 at 10:01 AM, Cuero Bugot <cbugot@sierrawireless.com> wrote:
> 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)

Someone did some research on the topic a few years ago:

http://lua-users.org/wiki/SpeedingUpStrings