aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2017-03-09 01:20:59 +0100
committerKim Alvefur <zash@zash.se>2017-03-09 01:20:59 +0100
commit384687ffa49ac61dddb91be1ec5de1572ba2c036 (patch)
treebbd6a9c2b24a4bbf263cc2645276de0bcdfd23ae
parente1a8887ccd0b60d06eb823242572b4526014fe80 (diff)
downloadprosody-384687ffa49ac61dddb91be1ec5de1572ba2c036.tar.gz
prosody-384687ffa49ac61dddb91be1ec5de1572ba2c036.zip
util-src: Specify size of various tables to be allocated
-rw-r--r--util-src/crand.c2
-rw-r--r--util-src/net.c2
-rw-r--r--util-src/pposix.c4
-rw-r--r--util-src/ringbuffer.c4
-rw-r--r--util-src/table.c2
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);