[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: String buffers
- From: Klaus Ripke <paul-lua@...>
- Date: Sun, 5 Feb 2006 00:07:22 +0100
On Sun, Feb 05, 2006 at 12:22:26AM +0200, Asko Kauppi wrote:
> Hm, I was thinking of suggesting that (local buffer) to David, but
> that's way too bad design considering multithreaded applications.
clearly the only reasonable use of static buffers is by the main routine.
> But having the local buffer in stack (not 'static') is safe; David,
> is that an option?
> char buffer;
> int length = myapi(NULL, 0);
> assert( length <= sizeof(buffer) );
> (void) myapi(buffer, length);
> lua_pushlstring(L, buffer, length);
> Of course, one can resort to the malloc code, if length turns out to
> be too big (instead of assertion).
on stack, of course.
For MT environments, 2MB stack is typical,
so using about 64-256K or so in a non-recursive function is usually
For ST you can use much more on most platforms.