From cfbbf68f8af83521b41b40c07db48897b976b626 Mon Sep 17 00:00:00 2001 From: shishir gowda Date: Tue, 14 Sep 2010 23:43:39 +0000 Subject: Cleaning up mem_get0. mem_get0 is exactly the same as mem_get, but with the addition of a call to memset(0). hence, making mem_get0 to call mem_get Signed-off-by: shishir gowda Signed-off-by: Vijay Bellur BUG: 1520 (gnfs crashes on start-up in mem_get0) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1520 --- libglusterfs/src/mem-pool.c | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'libglusterfs/src/mem-pool.c') diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c index d11bcbcae..3df317a5c 100644 --- a/libglusterfs/src/mem-pool.c +++ b/libglusterfs/src/mem-pool.c @@ -341,39 +341,17 @@ mem_pool_new_fn (unsigned long sizeof_type, void* mem_get0 (struct mem_pool *mem_pool) { - struct list_head *list = NULL; void *ptr = NULL; - int *in_use = NULL; if (!mem_pool) { gf_log ("mem-pool", GF_LOG_ERROR, "invalid argument"); return NULL; } - LOCK (&mem_pool->lock); - { - if (mem_pool->cold_count) { - list = mem_pool->list.next; - list_del (list); - - mem_pool->hot_count++; - mem_pool->cold_count--; + ptr = mem_get(mem_pool); - ptr = list; - in_use = (ptr + GF_MEM_POOL_LIST_BOUNDARY); - *in_use = 1; - - goto fwd_addr_out; - } - ptr = MALLOC (mem_pool->real_sizeof_type); - goto unlocked_out; - } -fwd_addr_out: - ptr = mem_pool_chunkhead2ptr (ptr); -unlocked_out: - - memset(ptr, 0, mem_pool->real_sizeof_type); - UNLOCK (&mem_pool->lock); + if (ptr) + memset(ptr, 0, mem_pool->real_sizeof_type); return ptr; } -- cgit