size_t lua_objlen (lua_State *L, int index);

Returns the "length" of the value at the given acceptable index: for strings, this is the string length; for tables, this is the result of the length operator ('=#='); for userdata, this is the size of the block of memory allocated for the userdata; for other values, it is 0.