From 63cb7c0f364df3331df235f38f1be901f04bebba Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 14 Mar 2011 21:29:35 +0300 Subject: [PATCH] Optimization. --- src/lua/lua_task.c | 13 +++---------- src/mem_pool.c | 18 +++--------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/src/lua/lua_task.c b/src/lua/lua_task.c index eb95f0258..f161eca5e 100644 --- a/src/lua/lua_task.c +++ b/src/lua/lua_task.c @@ -466,7 +466,7 @@ lua_dns_callback (struct rspamd_dns_reply *reply, gpointer arg) cur = reply->elements; while (cur) { elt = cur->data; - memcpy (&ina, elt->a.addr, sizeof (in_addr_t)); + memcpy (&ina, &elt->a.addr[0], sizeof (struct in_addr)); /* Actually this copy memory, so using of inet_ntoa is valid */ lua_pushstring (cd->L, inet_ntoa (ina)); lua_rawseti (cd->L, -2, ++i); @@ -474,7 +474,7 @@ lua_dns_callback (struct rspamd_dns_reply *reply, gpointer arg) } lua_pushnil (cd->L); } - else if (reply->type == DNS_REQUEST_A) { + else if (reply->type == DNS_REQUEST_PTR) { lua_newtable (cd->L); cur = reply->elements; while (cur) { @@ -811,16 +811,9 @@ static gint lua_task_get_recipients_headers (lua_State *L) { struct worker_task *task = lua_check_task (L); - InternetAddressList *addrs; if (task) { - addrs = g_mime_message_get_all_recipients(task->message); - lua_push_internet_address (L, addrs); -#ifndef GMIME24 - internet_address_list_destroy (addrs); -#else - g_object_unref (addrs); -#endif + lua_push_internet_address (L, task->rcpts); return 1; } diff --git a/src/mem_pool.c b/src/mem_pool.c index 161da4f01..ac870d42b 100644 --- a/src/mem_pool.c +++ b/src/mem_pool.c @@ -205,7 +205,7 @@ memory_pool_alloc (memory_pool_t * pool, gsize size) } else { mem_pool_stat->oversized_chunks++; - new = pool_chain_new (size + cur->len); + new = pool_chain_new (size + pool->first_pool->len); } /* Attach new pool to chain */ cur->next = new; @@ -231,7 +231,7 @@ memory_pool_alloc0 (memory_pool_t * pool, gsize size) { void *pointer = memory_pool_alloc (pool, size); if (pointer) { - bzero (pointer, size); + memset (pointer, 0, size); } return pointer; } @@ -241,7 +241,7 @@ memory_pool_alloc0_shared (memory_pool_t * pool, gsize size) { void *pointer = memory_pool_alloc_shared (pool, size); if (pointer) { - bzero (pointer, size); + memset (pointer, 0, size); } return pointer; } @@ -445,18 +445,6 @@ memory_pool_add_destructor_full (memory_pool_t * pool, pool_destruct_func func, cur = memory_pool_alloc (pool, sizeof (struct _pool_destructors)); if (cur) { - /* Check whether we have identical destructor in pool */ - tmp = pool->destructors; - while (tmp) { - if (tmp->func == func && tmp->data == data) { - /* Do not add identical destructors, they must be unique */ - msg_warn ("duplicate desctrutors detected: already have destructor from %s:%s and is trying to add from %s:%s", - tmp->function, tmp->loc, function, line); - return; - } - tmp = tmp->prev; - } - cur->func = func; cur->data = data; cur->function = function; -- 2.39.5