A luaL_Buffer is limited to 8KiB, so use a heap buffer instead to ensure it is large enough to hold the object. This keeps a small local stack scratch area for small objects to avoid heap allocations for items that will fit in this, and uses the heap for everything else.
A luaL_Buffer is limited to 8KiB, so use a heap buffer instead to ensure it is large enough to hold the object. This keeps a small local stack scratch area for small objects to avoid heap allocations for items that will fit in this, and uses the heap for everything else.