Lua C-API を使用して 2 つLuaL_Buffer
の s を連結する効率的な方法はありますか? 不要な memcopy を実行したくないので、結果をluaL_pushresult()
. バッファーにはゼロが埋め込まれているため、それらを char 配列に変換して使用することはできませんluaL_addstring()
。どちらのバッファも変更できます。
luaL_Buffer buf1;
luaL_Buffer buf2;
luaL_buffinit(L, &buf1);
luaL_buffinit(L, &buf2);
luaL_addchar(&buf1, "a");
luaL_addchar(&buf2, "b");
luaL_addchar(&buf1, "\0");
luaL_addchar(&buf2, "\0");
luaL_pushresult(L, Want_this(&buf1, &buf2) ); // "a\0b\0" is now the Lua string
// at the top of the stack