Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8276551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T08:24:33+00:00 2026-06-08T08:24:33+00:00

Given that the LuaL_Buffer object: During its normal operation, a string buffer uses a

  • 0

Given that the LuaL_Buffer object: “During its normal operation, a string buffer uses a variable number of stack slots“, I don’t understand how two luaL_Buffer objects can be used at the same time. Will they each assume the state of the stack is as they require? In other words, one buffer might put something on the top of the stack and expect it to be there in some future call, while the same being true for another buffer? Is it not possible to work with two LuaL_Buffers at the same time?

Here is an example of some operation that requires two buffers at the same time. It seems to work for small tests, but don’t know if it will stand up in production.

int res;
char *p;
size_t dlen;
struct luaL_Buffer src;
struct luaL_Buffer dst;

luaL_buffinit(L, &src);
luaL_buffinit(L, &dst);
luaL_addvalue(&src);
// .. grow/mod the src buffer in various ways
p = luaL_prepbuffsize(&dst, dlen);
res = my_uncompress((Byte *)(src.b), src.n, (Byte *)p, &dlen);
luaL_addsize(&dst, dlen);
// .. do things to the dst buffer ..

where my_uncompress is wrapper to a zlib method

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T08:24:34+00:00Added an answer on June 8, 2026 at 8:24 am

    You generally can’t use two luaL_Buffers at the same time. Just as you can’t use mess around with the stack while in the middle of a function that assumes you don’t mess with the stack.

    You can use two luaL_Buffers, but only if you fully nest the calls. That is, the first buffer you prepped cannot be modified as long as the second buffer you prepped hasn’t been finished with luaL_pushresult.

    The absolute best you can do is use lua_newthread to create a new thread stack and put each buffer into its own thread. However, this is a terrible abuse of the API, and I wouldn’t suggest it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that an input String may be specified as follows: read(xpath(‘...’)) or xpath(‘...’) or
Given that users must be able to define their own fields on an object,
Given that I have an IEnumerable<T> , where T is any object, how can
Given that JTextArea t = new JTextArea(); Document d = t.getDocument(); String word1 =
Given that a ThreadLocal variable holds different values for different threads, is it possible
given that a n-byte array can be represented as a 2*n character string using
Given that I have a Gallery object and Photo object. Gallery has many Photos.
Given that the web application doesn't have su privileges, I'd like to execute a
Given that I have a Foo model w/ the standard Rails timestamp columns what
Given that sorl isn't an app directory wide and the template tag definition lives

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.