guint8 *ptr;
if (ip != NULL && ip->addr) {
- lua_newtable (L);
ptr = rspamd_inet_address_get_hash_key (ip->addr, &max);
+ lua_createtable (L, max, 0);
for (i = 1; i <= max; i++, ptr++) {
lua_pushnumber (L, *ptr);
char numbuf[8];
if (ip != NULL && ip->addr) {
- lua_newtable (L);
af = rspamd_inet_address_get_af (ip->addr);
ptr = rspamd_inet_address_get_hash_key (ip->addr, &max);
+ lua_createtable (L, max * 2, 0);
for (i = 1; i <= max; i++, ptr++) {
if (af == AF_INET) {
gint af;
if (ip != NULL && ip->addr) {
- lua_newtable (L);
ptr = rspamd_inet_address_get_hash_key (ip->addr, &max);
af = rspamd_inet_address_get_af (ip->addr);
+ lua_createtable (L, max * 2, 0);
ptr += max - 1;
for (i = 1; i <= max; i++, ptr--) {
struct rspamd_task *task = lua_check_task (L, 1);
struct lua_tree_cb_data cb;
gboolean need_emails = FALSE;
+ gsize sz;
if (task) {
if (lua_gettop (L) >= 2) {
need_emails = lua_toboolean (L, 2);
}
- lua_newtable (L);
+ sz = g_hash_table_size (task->urls);
+
+ if (need_emails) {
+ sz += g_hash_table_size (task->emails);
+ }
+
+ lua_createtable (L, sz, 0);
cb.i = 1;
cb.L = L;
g_hash_table_foreach (task->urls, lua_tree_url_callback, &cb);
struct lua_tree_cb_data cb;
if (task) {
- lua_newtable (L);
+ lua_createtable (L, g_hash_table_size (task->emails), 0);
cb.i = 1;
cb.L = L;
g_hash_table_foreach (task->emails, lua_tree_url_callback, &cb);
struct rspamd_mime_text_part *part, **ppart;
if (task != NULL) {
- lua_newtable (L);
+ lua_createtable (L, task->text_parts->len, 0);
for (i = 0; i < task->text_parts->len; i ++) {
part = g_ptr_array_index (task->text_parts, i);
struct rspamd_mime_part *part, **ppart;
if (task != NULL) {
- lua_newtable (L);
+ lua_createtable (L, task->parts->len, 0);
for (i = 0; i < task->parts->len; i ++) {
part = g_ptr_array_index (task->parts, i);
struct rspamd_archive **parch;
if (task) {
- lua_newtable (L);
+ lua_createtable (L, task->parts->len, 0);
for (i = 0; i < task->parts->len; i ++) {
part = g_ptr_array_index (task->parts, i);
opt = s->options;
lua_pushstring (L, "options");
lua_newtable (L);
+
while (opt) {
lua_pushstring (L, opt->data);
lua_rawseti (L, -2, j++);
opt = g_list_next (opt);
}
+
lua_settable (L, -3);
}
struct rspamd_task *task = lua_check_task (L, 1);
if (task != NULL) {
- lua_newtable (L);
+ lua_createtable (L, 0, 2);
lua_pushstring (L, "tv_sec");
lua_pushnumber (L, (lua_Number)task->tv.tv_sec);
lua_settable (L, -3);
guint flags, bit, i;
if (task) {
- lua_newtable (L);
+ lua_createtable (L, 8, 0);
flags = task->flags;
if (task && metric_name) {
if ((metric_res =
g_hash_table_lookup (task->results, metric_name)) != NULL) {
- lua_newtable (L);
+ lua_createtable (L, 2, 0);
lua_pushnumber (L, metric_res->score);
rs = rspamd_task_get_required_score (task, metric_res);
lua_rawseti (L, -2, 1);
lua_pushnil (L);
}
else {
- lua_newtable (L);
+ lua_createtable (L, res->len, 0);
for (i = 0; i < res->len; i ++) {
w = &g_array_index (res, rspamd_ftok_t, i);
}
else {
cnt = internet_address_list_length (ia);
- lua_newtable (L);
+ lua_createtable (L, cnt, 0);
for (i = 0; i < cnt; i ++) {
addr = internet_address_list_get_address (ia, i);
- lua_newtable (L);
+ lua_createtable (L, 0, 2);
lua_pushstring (L, "name");
lua_pushstring (L, internet_address_get_name (addr));
lua_settable (L, -3);
}
}
- lua_newtable (L);
+ lua_createtable (L, gl.gl_pathc, 0);
/* Push results */
for (i = 0; i < (gint)gl.gl_pathc; i ++) {
lua_pushstring (L, gl.gl_pathv[i]);