[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String buffers
- From: Asko Kauppi <askok@...>
- Date: Sat, 4 Feb 2006 19:47:19 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
No, I think not (without patching the Lua C/API, that is).
David Given kirjoitti 2.2.2006 kello 19.44:
I'm trying to wrap a particular API function that writes a string
into a
buffer.
I can call the function to tell me how long the buffer needs to be,
and I can
call it again to actually write the string:
{
int length = myapi(NULL, 0);
char* buffer = malloc(length);
(void) myapi(buffer, length);
lua_pushlstring(L, buffer, length);
free(buffer);
}
I'd like to avoid the temporary buffer. Is there any way of
persuading Lua to
allocate an *uninitialised* string of a particular length on the
stack, and
then giving me a pointer to it so I can fill in that data one's the
string's
been allocated?
--
+- David Given --McQ-+ "There is nothing in the world so dangerous ---
| dg@cowlark.com | and I mean *nothing* --- as a children's
story that
| (dg@tao-group.com) | happens to be true." --- Master Li Kao, _The
Bridge
+- www.cowlark.com --+ of Birds_
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (Darwin)
iD8DBQFD5OioGJtHlJZfjQoRAoYIAJ9ltk84TektK/0iBo6YJi1/QLUoCgCfZ0Ad
FBh1EQYUFlu4ZZK7l0iAf+s=
=vOdW
-----END PGP SIGNATURE-----