[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Is it ok to assume luaL_ref() won't return 0 ?
- From: Niccolo Medici <niccolomedici@...>
- Date: Fri, 5 Aug 2016 14:22:24 +0300
Let's say I have a C 'int' variable that holds a reference (what
luaL_ref() returns). At the start of the program it's initialized to
zero. Can I assume that zero means that it doesn't hold a reference,
or must I explicitly initialize it to LUA_NOREF (which happens to be
(It's not that I'm being lazy. In reality I have several huge arrays
of references (allocated and zero'ed with calloc()), not just one
variable, and I want to skip the loops that are to initialize them.)
A bonus question: if it's ok to assume luaL_ref() won't return 0, then
why does LUA_NOREF equal -2 instead of simply being 0 ?