diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2013-06-30 11:26:02 +0400 |
---|---|---|
committer | Kozlov Dmitry <xeb@mail.ru> | 2013-06-30 11:29:03 +0400 |
commit | b77ca8764985ebae18d769cdf115e2242bbac98d (patch) | |
tree | 3c6c59c9f56e7632c96a578ee4f8e14e0b232055 | |
parent | 4692715663ae0c793cd754db95b91bb80521d5a2 (diff) | |
download | accel-ppp-b77ca8764985ebae18d769cdf115e2242bbac98d.tar.gz accel-ppp-b77ca8764985ebae18d769cdf115e2242bbac98d.zip |
mempool: set/check magic only if MEMDEBUG defined
-rw-r--r-- | accel-pppd/triton/mempool.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/accel-pppd/triton/mempool.c b/accel-pppd/triton/mempool.c index 5323771..1ee00f3 100644 --- a/accel-pppd/triton/mempool.c +++ b/accel-pppd/triton/mempool.c @@ -29,9 +29,9 @@ struct _mempool_t struct list_head items; #ifdef MEMDEBUG struct list_head ditems; + uint64_t magic; #endif spinlock_t lock; - uint64_t magic; int mmap:1; int objects; }; @@ -46,9 +46,9 @@ struct _item_t #ifdef MEMDEBUG const char *fname; int line; -#endif uint64_t magic2; uint64_t magic1; +#endif char ptr[0]; }; @@ -69,10 +69,10 @@ mempool_t __export *mempool_create(int size) INIT_LIST_HEAD(&p->items); #ifdef MEMDEBUG INIT_LIST_HEAD(&p->ditems); + p->magic = (uint64_t)random() * (uint64_t)random(); #endif spinlock_init(&p->lock); p->size = size; - p->magic = (uint64_t)random() * (uint64_t)random(); spin_lock(&pools_lock); list_add_tail(&p->entry, &pools); @@ -106,8 +106,6 @@ void __export *mempool_alloc(mempool_t *pool) --p->objects; __sync_sub_and_fetch(&triton_stat.mempool_available, size); - it->magic1 = MAGIC1; - return it->ptr; #ifdef VALGRIND } @@ -135,9 +133,6 @@ void __export *mempool_alloc(mempool_t *pool) return NULL; } it->owner = p; - it->magic2 = p->magic; - it->magic1 = MAGIC1; - *(uint64_t*)(it->ptr + p->size) = it->magic2; return it->ptr; } |