rspamd_lua_setclass (L, "rspamd{text}", -1);
t->start = part->content->data;
t->len = part->content->len;
+ t->own = FALSE;
return 1;
}
rspamd_lua_setclass (L, "rspamd{text}", -1);
t->start = part->content->data;
t->len = part->content->len;
+ t->own = FALSE;
return 1;
}
LUA_FUNCTION_DEF (text, len);
LUA_FUNCTION_DEF (text, str);
LUA_FUNCTION_DEF (text, ptr);
+LUA_FUNCTION_DEF (text, gc);
static const struct luaL_reg textlib_m[] = {
LUA_INTERFACE_DEF (text, len),
LUA_INTERFACE_DEF (text, str),
LUA_INTERFACE_DEF (text, ptr),
{"__tostring", lua_text_str},
+ {"__gc", lua_text_gc},
{NULL, NULL}
};
rspamd_lua_setclass (L, "rspamd{text}", -1);
t->len = task->msg.len;
t->start = task->msg.start;
+ t->own = FALSE;
return 1;
}
rspamd_lua_setclass (L, "rspamd{text}", -1);
t->start = task->raw_headers_str;
t->len = strlen (t->start);
+ t->own = FALSE;
}
else {
lua_pushnil (L);
return 1;
}
+static gint
+lua_text_gc (lua_State *L)
+{
+ struct rspamd_lua_text *t = lua_check_text (L, 1);
+
+ if (t != NULL && t->own) {
+ g_free ((gpointer)t->start);
+ }
+
+ return 0;
+}
+
/* Init part */
static gint
rspamd_lua_setclass (cbd->L, "rspamd{text}", -1);
t->start = str;
t->len = len;
+ t->own = FALSE;
if (lua_pcall (cbd->L, 2, 0, 0) != 0) {
msg_info ("callback call failed: %s", lua_tostring (cbd->L, -1));