Fixes from Google-internal.

pull/13171/head
Josh Haberman 10 years ago
parent e5bcdc2a3f
commit 19a973a85e
  1. 2
      upb/bindings/lua/upb.c
  2. 5
      upb/bindings/lua/upb.lua
  3. 2
      upb/pb/textprinter.c
  4. 16
      upb/table.c

@ -53,7 +53,7 @@ static size_t lupb_msgdef_sizeof();
* compatibility code can help hide the difference. Not too many people still
* use Lua 5.1 but LuaJIT uses the Lua 5.1 API in some ways. */
#if lua_version_num == 501
#if LUA_VERSION_NUM == 501
/* taken from lua 5.2's source. */
void *luaL_testudata(lua_State *L, int ud, const char *tname) {

@ -14,7 +14,10 @@
-- This has to happen *before* the require call, because if the module
-- is loaded RTLD_LOCAL first, a subsequent load as RTLD_GLOBAL won't
-- have the proper effect, at least on some platforms.
package.loadlib(package.searchpath("upb_c", package.cpath), "*")
local so = package.searchpath and package.searchpath("upb_c", package.cpath)
if so then
package.loadlib(so, "*")
end
local upb = require("upb_c")

@ -112,7 +112,7 @@ bool putf(upb_textprinter *p, const char *fmt, ...) {
/* Run once to get the length of the string. */
va_copy(args_copy, args);
len = vsprintf(NULL, fmt, args_copy);
len = _upb_vsnprintf(NULL, 0, fmt, args_copy);
va_end(args_copy);
/* + 1 for NULL terminator (vsprintf() requires it even if we don't). */

@ -439,14 +439,16 @@ size_t upb_inttable_count(const upb_inttable *t) {
static void check(upb_inttable *t) {
UPB_UNUSED(t);
#if defined(UPB_DEBUG_TABLE) && !defined(NDEBUG)
/* This check is very expensive (makes inserts/deletes O(N)). */
size_t count = 0;
upb_inttable_iter i;
upb_inttable_begin(&i, t);
for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) {
assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL));
{
/* This check is very expensive (makes inserts/deletes O(N)). */
size_t count = 0;
upb_inttable_iter i;
upb_inttable_begin(&i, t);
for(; !upb_inttable_done(&i); upb_inttable_next(&i), count++) {
assert(upb_inttable_lookup(t, upb_inttable_iter_key(&i), NULL));
}
assert(count == upb_inttable_count(t));
}
assert(count == upb_inttable_count(t));
#endif
}

Loading…
Cancel
Save