summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/rbthash.c
diff options
context:
space:
mode:
authorVijay Bellur <vijay@gluster.com>2010-04-22 13:33:09 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-04-23 06:32:52 -0700
commit582de0677da4be19fc6f873625c58c45d069ab1c (patch)
treef10cb3e26e1f92f6ea91034e6f7bb925790dd9bc /libglusterfs/src/rbthash.c
parent72baa17282f5cf749fa743fd601c7b728ece4fa2 (diff)
Memory accounting changes
Memory accounting Changes. Thanks to Vinayak Hegde and Csaba Henk for their contributions. Signed-off-by: Vijay Bellur <vijay@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 329 (Replacing memory allocation functions with mem-type functions) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=329
Diffstat (limited to 'libglusterfs/src/rbthash.c')
-rw-r--r--libglusterfs/src/rbthash.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/libglusterfs/src/rbthash.c b/libglusterfs/src/rbthash.c
index 33e80224a87..b5e684def18 100644
--- a/libglusterfs/src/rbthash.c
+++ b/libglusterfs/src/rbthash.c
@@ -116,11 +116,13 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
}
- newtab = CALLOC (1, sizeof (*newtab));
+ newtab = GF_CALLOC (1, sizeof (*newtab),
+ gf_common_mt_rbthash_table_t);
if (!newtab)
return NULL;
- newtab->buckets = CALLOC (buckets, sizeof (struct rbthash_bucket));
+ newtab->buckets = GF_CALLOC (buckets, sizeof (struct rbthash_bucket),
+ gf_common_mt_rbthash_bucket);
if (!newtab->buckets) {
gf_log (GF_RBTHASH, GF_LOG_ERROR, "Failed to allocate memory");
goto free_newtab;
@@ -157,11 +159,11 @@ rbthash_table_init (int buckets, rbt_hasher_t hfunc,
free_buckets:
if (ret == -1)
- FREE (newtab->buckets);
+ GF_FREE (newtab->buckets);
free_newtab:
if (ret == -1) {
- FREE (newtab);
+ GF_FREE (newtab);
newtab = NULL;
}
@@ -185,7 +187,7 @@ rbthash_init_entry (rbthash_table_t *tbl, void *data, void *key, int keylen)
}
entry->data = data;
- entry->key = CALLOC (keylen, sizeof (char));
+ entry->key = GF_CALLOC (keylen, sizeof (char), gf_common_mt_char);
if (!entry->key) {
gf_log (GF_RBTHASH, GF_LOG_ERROR, "Memory allocation failed");
goto free_entry;
@@ -216,7 +218,7 @@ rbthash_deinit_entry (rbthash_table_t *tbl, rbthash_entry_t *entry)
return;
if (entry->key)
- FREE (entry->key);
+ GF_FREE (entry->key);
if (tbl) {
if ((entry->data) && (tbl->dfunc))
@@ -374,7 +376,7 @@ rbthash_remove (rbthash_table_t *tbl, void *key, int keylen)
if (!entry)
return NULL;
- FREE (entry->key);
+ GF_FREE (entry->key);
dataref = entry->data;
mem_put (tbl->entrypool, entry);
@@ -418,7 +420,7 @@ rbthash_table_destroy (rbthash_table_t *tbl)
if (tbl->pool_alloced)
mem_pool_destroy (tbl->entrypool);
- FREE (tbl->buckets);
- FREE (tbl);
+ GF_FREE (tbl->buckets);
+ GF_FREE (tbl);
}