aboutsummaryrefslogtreecommitdiffstats
path: root/src/mem_pool.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-03 13:59:12 +0400
committerVsevolod Stakhov <vsevolod@rambler-co.ru>2009-09-03 13:59:12 +0400
commitc9d98a8fc24f76d979ad479eff2fa66b31703832 (patch)
tree3e7da89081fd35425db582dacbdd3277adf40aaf /src/mem_pool.c
parent563a106f3a57e460b9c5ea06a2eb4e6456f9e080 (diff)
downloadrspamd-c9d98a8fc24f76d979ad479eff2fa66b31703832.tar.gz
rspamd-c9d98a8fc24f76d979ad479eff2fa66b31703832.zip
* Various bugfixes in map and radix code
Diffstat (limited to 'src/mem_pool.c')
-rw-r--r--src/mem_pool.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/mem_pool.c b/src/mem_pool.c
index e8be6a95c..ce6eab86e 100644
--- a/src/mem_pool.c
+++ b/src/mem_pool.c
@@ -60,7 +60,13 @@ pool_chain_new (memory_pool_ssize_t size)
g_assert (size > 0);
chain = g_slice_alloc (sizeof (struct _pool_chain));
+
+ g_assert (chain != NULL);
+
chain->begin = g_slice_alloc (size);
+
+ g_assert (chain->begin != NULL);
+
chain->len = size;
chain->pos = chain->begin;
chain->next = NULL;
@@ -78,10 +84,9 @@ pool_chain_new_shared (memory_pool_ssize_t size)
#if defined(HAVE_MMAP_ANON)
chain = mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0);
+ g_assert (chain != MAP_FAILED);
chain->begin = ((u_char *)chain) + sizeof (struct _pool_chain_shared);
- if (chain == MAP_FAILED) {
- return NULL;
- }
+ g_assert (chain->begin != MAP_FAILED);
#elif defined(HAVE_MMAP_ZERO)
int fd;
@@ -90,10 +95,9 @@ pool_chain_new_shared (memory_pool_ssize_t size)
return NULL;
}
chain = mmap (NULL, size + sizeof (struct _pool_chain_shared), PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+ g_assert (chain != MAP_FAILED);
chain->begin = ((u_char *)chain) + sizeof (struct _pool_chain_shared);
- if (chain == MAP_FAILED) {
- return NULL;
- }
+ g_assert (chain->begin != MAP_FAILED);
#else
# error No mmap methods are defined
#endif
@@ -138,6 +142,8 @@ memory_pool_new (memory_pool_ssize_t size)
}
new = g_slice_alloc (sizeof (memory_pool_t));
+ g_assert (new != NULL);
+
new->cur_pool = pool_chain_new (size);
new->shared_pool = NULL;
new->first_pool = new->cur_pool;