From d367c8c3ce3f0c0665a402dc9eadde29aade7b61 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 9 Mar 2017 01:20:59 +0100 Subject: util-src: Specify size of various tables to be allocated --- util-src/crand.c | 2 +- util-src/net.c | 2 +- util-src/pposix.c | 4 ++-- util-src/ringbuffer.c | 4 ++-- util-src/table.c | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/util-src/crand.c b/util-src/crand.c index ef9da4d2..d4b84327 100644 --- a/util-src/crand.c +++ b/util-src/crand.c @@ -100,7 +100,7 @@ int luaopen_util_crand(lua_State *L) { luaL_checkversion(L); #endif - lua_newtable(L); + lua_createtable(L, 0, 2); lua_pushcfunction(L, Lrandom); lua_setfield(L, -2, "bytes"); diff --git a/util-src/net.c b/util-src/net.c index 35f2c362..bb159d57 100644 --- a/util-src/net.c +++ b/util-src/net.c @@ -134,7 +134,7 @@ int luaopen_util_net(lua_State *L) { { NULL, NULL } }; - lua_newtable(L); + lua_createtable(L, 0, 1); luaL_setfuncs(L, exports, 0); return 1; } diff --git a/util-src/pposix.c b/util-src/pposix.c index c0cced5c..4b4552f5 100644 --- a/util-src/pposix.c +++ b/util-src/pposix.c @@ -660,7 +660,7 @@ int lc_uname(lua_State *L) { return 2; } - lua_newtable(L); + lua_createtable(L, 0, 6); lua_pushstring(L, uname_info.sysname); lua_setfield(L, -2, "sysname"); lua_pushstring(L, uname_info.nodename); @@ -709,7 +709,7 @@ int lc_setenv(lua_State *L) { #ifdef WITH_MALLINFO int lc_meminfo(lua_State *L) { struct mallinfo info = mallinfo(); - lua_newtable(L); + lua_createtable(L, 0, 5); /* This is the total size of memory allocated with sbrk by malloc, in bytes. */ lua_pushinteger(L, info.arena); lua_setfield(L, -2, "allocated"); diff --git a/util-src/ringbuffer.c b/util-src/ringbuffer.c index 2a13903c..8d9e49e6 100644 --- a/util-src/ringbuffer.c +++ b/util-src/ringbuffer.c @@ -187,7 +187,7 @@ int luaopen_util_ringbuffer(lua_State *L) { lua_pushcfunction(L, rb_length); lua_setfield(L, -2, "__len"); - lua_newtable(L); /* __index */ + lua_createtable(L, 0, 7); /* __index */ { lua_pushcfunction(L, rb_find); lua_setfield(L, -2, "find"); @@ -207,7 +207,7 @@ int luaopen_util_ringbuffer(lua_State *L) { lua_setfield(L, -2, "__index"); } - lua_newtable(L); + lua_createtable(L, 0, 1); lua_pushcfunction(L, rb_new); lua_setfield(L, -2, "new"); return 1; diff --git a/util-src/table.c b/util-src/table.c index f1cd9e12..9a9553fc 100644 --- a/util-src/table.c +++ b/util-src/table.c @@ -24,7 +24,7 @@ int luaopen_util_table(lua_State *L) { #if (LUA_VERSION_NUM > 501) luaL_checkversion(L); #endif - lua_newtable(L); + lua_createtable(L, 0, 2); lua_pushcfunction(L, Lcreate_table); lua_setfield(L, -2, "create"); lua_pushcfunction(L, Lpack); -- cgit v1.2.3