aboutsummaryrefslogtreecommitdiffstats
path: root/src/lua/lua_mempool.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:45:28 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2014-07-23 12:45:28 +0100
commite0483657ff6cf1adc828ccce457814d61fe90a0d (patch)
tree5183e4163f40b81b3e7d5f51488d360883782154 /src/lua/lua_mempool.c
parent7962087e808fb824aa3af6d41d02abc92916ba1e (diff)
downloadrspamd-e0483657ff6cf1adc828ccce457814d61fe90a0d.tar.gz
rspamd-e0483657ff6cf1adc828ccce457814d61fe90a0d.zip
Unify code style.
Diffstat (limited to 'src/lua/lua_mempool.c')
-rw-r--r--src/lua/lua_mempool.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/lua/lua_mempool.c b/src/lua/lua_mempool.c
index 2648a60b2..50de17dd1 100644
--- a/src/lua/lua_mempool.c
+++ b/src/lua/lua_mempool.c
@@ -25,7 +25,7 @@
#include "mem_pool.h"
/* Public prototypes */
-struct memory_pool_s *lua_check_mempool (lua_State * L);
+struct memory_pool_s * lua_check_mempool (lua_State * L);
gint luaopen_mempool (lua_State * L);
/* Lua bindings */
@@ -37,7 +37,7 @@ LUA_FUNCTION_DEF (mempool, memory_pool_suggest_size);
LUA_FUNCTION_DEF (mempool, memory_pool_set_variable);
LUA_FUNCTION_DEF (mempool, memory_pool_get_variable);
-static const struct luaL_reg mempoollib_m[] = {
+static const struct luaL_reg mempoollib_m[] = {
LUA_INTERFACE_DEF (mempool, memory_pool_add_destructor),
LUA_INTERFACE_DEF (mempool, memory_pool_stat),
LUA_INTERFACE_DEF (mempool, memory_pool_suggest_size),
@@ -48,7 +48,7 @@ static const struct luaL_reg mempoollib_m[] = {
{NULL, NULL}
};
-static const struct luaL_reg mempoollib_f[] = {
+static const struct luaL_reg mempoollib_f[] = {
LUA_INTERFACE_DEF (mempool, create),
{NULL, NULL}
};
@@ -63,10 +63,10 @@ struct lua_mempool_udata {
rspamd_mempool_t *mempool;
};
-struct memory_pool_s *
+struct memory_pool_s *
lua_check_mempool (lua_State * L)
{
- void *ud = luaL_checkudata (L, 1, "rspamd{mempool}");
+ void *ud = luaL_checkudata (L, 1, "rspamd{mempool}");
luaL_argcheck (L, ud != NULL, 1, "'mempool' expected");
return ud ? *((struct memory_pool_s **)ud) : NULL;
}
@@ -75,7 +75,8 @@ lua_check_mempool (lua_State * L)
static int
lua_mempool_create (lua_State *L)
{
- struct memory_pool_s *mempool = rspamd_mempool_new (rspamd_mempool_suggest_size ()), **pmempool;
+ struct memory_pool_s *mempool = rspamd_mempool_new (
+ rspamd_mempool_suggest_size ()), **pmempool;
if (mempool) {
pmempool = lua_newuserdata (L, sizeof (struct memory_pool_s *));
@@ -92,7 +93,7 @@ lua_mempool_create (lua_State *L)
static void
lua_mempool_destructor_func (gpointer p)
{
- struct lua_mempool_udata *ud = p;
+ struct lua_mempool_udata *ud = p;
lua_rawgeti (ud->L, LUA_REGISTRYINDEX, ud->cbref);
if (lua_pcall (ud->L, 0, 0, 0) != 0) {
@@ -104,18 +105,21 @@ lua_mempool_destructor_func (gpointer p)
static int
lua_mempool_memory_pool_add_destructor (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
- struct lua_mempool_udata *ud;
+ struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct lua_mempool_udata *ud;
if (mempool) {
if (lua_isfunction (L, 2)) {
- ud = rspamd_mempool_alloc (mempool, sizeof (struct lua_mempool_udata));
+ ud = rspamd_mempool_alloc (mempool,
+ sizeof (struct lua_mempool_udata));
lua_pushvalue (L, 2);
/* Get a reference */
ud->cbref = luaL_ref (L, LUA_REGISTRYINDEX);
ud->L = L;
ud->mempool = mempool;
- rspamd_mempool_add_destructor (mempool, lua_mempool_destructor_func, ud);
+ rspamd_mempool_add_destructor (mempool,
+ lua_mempool_destructor_func,
+ ud);
}
else {
msg_err ("trying to add destructor without function");
@@ -131,7 +135,7 @@ lua_mempool_memory_pool_add_destructor (lua_State *L)
static int
lua_mempool_memory_pool_delete (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = lua_check_mempool (L);
if (mempool) {
rspamd_mempool_delete (mempool);
@@ -147,10 +151,10 @@ lua_mempool_memory_pool_delete (lua_State *L)
static int
lua_mempool_memory_pool_stat (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = lua_check_mempool (L);
if (mempool) {
-
+
}
else {
lua_pushnil (L);
@@ -162,7 +166,7 @@ lua_mempool_memory_pool_stat (lua_State *L)
static int
lua_mempool_memory_pool_suggest_size (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
+ struct memory_pool_s *mempool = lua_check_mempool (L);
if (mempool) {
lua_pushinteger (L, rspamd_mempool_suggest_size ());
@@ -178,12 +182,13 @@ lua_mempool_memory_pool_suggest_size (lua_State *L)
static int
lua_mempool_memory_pool_set_variable (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
- const gchar *var = luaL_checkstring (L, 2),
- *value = luaL_checkstring (L, 3);
+ struct memory_pool_s *mempool = lua_check_mempool (L);
+ const gchar *var = luaL_checkstring (L, 2),
+ *value = luaL_checkstring (L, 3);
if (mempool && var && value) {
- rspamd_mempool_set_variable (mempool, var, rspamd_mempool_strdup (mempool, value), NULL);
+ rspamd_mempool_set_variable (mempool, var,
+ rspamd_mempool_strdup (mempool, value), NULL);
return 0;
}
else {
@@ -196,9 +201,9 @@ lua_mempool_memory_pool_set_variable (lua_State *L)
static int
lua_mempool_memory_pool_get_variable (lua_State *L)
{
- struct memory_pool_s *mempool = lua_check_mempool (L);
- const gchar *var = luaL_checkstring (L, 2);
- gchar *value;
+ struct memory_pool_s *mempool = lua_check_mempool (L);
+ const gchar *var = luaL_checkstring (L, 2);
+ gchar *value;
if (mempool && var) {
value = rspamd_mempool_get_variable (mempool, var);
@@ -228,10 +233,10 @@ luaopen_mempool (lua_State * L)
lua_pushstring (L, "rspamd{mempool}");
lua_rawset (L, -3);
- luaL_register (L, NULL, mempoollib_m);
+ luaL_register (L, NULL, mempoollib_m);
luaL_register (L, "rspamd_mempool", mempoollib_f);
lua_pop (L, 1); /* remove metatable from stack */
- return 1;
+ return 1;
}