Am 13.10.2014 um 17:10 schröbte Daurnimator: > On 10 October 2014 18:43, Philipp Janda <[email protected]> wrote: > >> >> Not if you do it right from the beginning. Having programmed in C++ >> usually helps, because you have a clear idea of object ownership, and >> Lua errors in combination with the Lua stack and the GC is a lot like >> C++ exceptions with automatic destructors. > > > In this circumstance; its perfectly valid to just use `alloca(3)`[1] and > just allocate on the stack.
This is basically the same as the variable length array (it also causes undefined behavior on stack overflow), but it isn't in any ISO C standard (or POSIX). Also, the portable fallback for `alloca`[3] that is included in many software projects allocates on the heap, not the stack. > No need to worry about malloc or even lua_newuserdata (though I do that > frequently too[2]) What do you have to worry about `lua_newuserdata`? It is a single fire-and-forget function call much like `alloca` ... Philipp > [1] http://linux.die.net/man/3/alloca > [2] e.g. > https://github.com/daurnimator/lua-systemd/blob/1a6fe1f60a/src/journal.c#L30 [3]: https://opensource.apple.com/source/gcc/gcc-1640/libiberty/alloca.c ------------------------------------------------------------------------------ Comprehensive Server Monitoring with Site24x7. Monitor 10 servers for $9/Month. Get alerted through email, SMS, voice calls or mobile push notifications. Take corrective actions from your mobile device. http://p.sf.net/sfu/Zoho _______________________________________________ Luarocks-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/luarocks-developers
