Software /
code /
prosody
Changeset
7969:1c6a07606309
util-src: Specify size of various tables to be allocated
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 09 Mar 2017 01:20:59 +0100 |
parents | 7968:f0e35f4db9e0 |
children | 7970:924354a35a02 7971:cd6f88012f67 |
files | util-src/crand.c util-src/net.c util-src/pposix.c util-src/ringbuffer.c util-src/table.c |
diffstat | 5 files changed, 7 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/util-src/crand.c Thu Mar 09 00:59:32 2017 +0100 +++ b/util-src/crand.c Thu Mar 09 01:20:59 2017 +0100 @@ -100,7 +100,7 @@ luaL_checkversion(L); #endif - lua_newtable(L); + lua_createtable(L, 0, 2); lua_pushcfunction(L, Lrandom); lua_setfield(L, -2, "bytes");
--- a/util-src/net.c Thu Mar 09 00:59:32 2017 +0100 +++ b/util-src/net.c Thu Mar 09 01:20:59 2017 +0100 @@ -134,7 +134,7 @@ { NULL, NULL } }; - lua_newtable(L); + lua_createtable(L, 0, 1); luaL_setfuncs(L, exports, 0); return 1; }
--- a/util-src/pposix.c Thu Mar 09 00:59:32 2017 +0100 +++ b/util-src/pposix.c Thu Mar 09 01:20:59 2017 +0100 @@ -660,7 +660,7 @@ 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 @@ #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");
--- a/util-src/ringbuffer.c Thu Mar 09 00:59:32 2017 +0100 +++ b/util-src/ringbuffer.c Thu Mar 09 01:20:59 2017 +0100 @@ -187,7 +187,7 @@ 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 @@ 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;
--- a/util-src/table.c Thu Mar 09 00:59:32 2017 +0100 +++ b/util-src/table.c Thu Mar 09 01:20:59 2017 +0100 @@ -24,7 +24,7 @@ #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);