From 53ff4f0299cf14c6c413d3e49991a6f05f9cda19 Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Wed, 28 Oct 2009 18:42:35 +0000 Subject: libglusterfs/rbtree: change rbthash_init_table to take no of expected entries in the hash table as argument. - the expected number of entries is used to create the memory pool of the hash table. Having constant macro for this purpose is not suitable since different users of rbtree based hash table store different number of entries in the table. Signed-off-by: Anand V. Avati BUG: 335 (Io-cache optimization) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=335 --- libglusterfs/src/rbthash.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libglusterfs/src/rbthash.c') diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c index 829257448..c2cbf99b4 100644 --- a/libglusterfs/src/rbthash.c +++ b/libglusterfs/src/rbthash.c @@ -80,7 +80,8 @@ err: rbthash_table_t * -rbthash_table_init (int buckets, rbt_hasher_t hfunc, rbt_data_destroyer_t dfunc) +rbthash_table_init (int buckets, rbt_hasher_t hfunc, rbt_data_destroyer_t dfunc, + unsigned long expected_entries) { rbthash_table_t *newtab = NULL; int ret = -1; @@ -100,7 +101,7 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc, rbt_data_destroyer_t dfunc) goto free_newtab; } - newtab->entrypool = mem_pool_new (rbthash_entry_t, GF_RBTHASH_MEMPOOL); + newtab->entrypool = mem_pool_new (rbthash_entry_t, expected_entries); if (!newtab->entrypool) { gf_log (GF_RBTHASH, GF_LOG_ERROR,"Failed to allocate mem-pool"); goto free_buckets; -- cgit