Skip to content

Commit

Permalink
Fixes from Google-internal.
Browse files Browse the repository at this point in the history
  • Loading branch information
haberman committed Jun 4, 2015
1 parent e5bcdc2 commit 19a973a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion upb/bindings/lua/upb.c
Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion upb/bindings/lua/upb.lua
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion upb/pb/textprinter.c
Expand Up @@ -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). */
Expand Down
16 changes: 9 additions & 7 deletions upb/table.c
Expand Up @@ -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
}

Expand Down

0 comments on commit 19a973a

Please sign in to comment.