lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

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
-2) ?

(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 ?