summaryrefslogtreecommitdiffstats
path: root/xlators/meta/src/tree.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 /xlators/meta/src/tree.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 'xlators/meta/src/tree.c')
-rw-r--r--xlators/meta/src/tree.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/xlators/meta/src/tree.c b/xlators/meta/src/tree.c
index a5ba08a3f3c..787f27da4f0 100644
--- a/xlators/meta/src/tree.c
+++ b/xlators/meta/src/tree.c
@@ -31,6 +31,7 @@
#include "xlator.h"
#include "meta.h"
+#include "meta-mem-types.h"
static int
is_meta_path (const char *path)
@@ -46,7 +47,7 @@ struct stat *
new_stbuf (void)
{
static int next_inode = 0;
- struct stat *stbuf = CALLOC (1, sizeof (struct stat));
+ struct stat *stbuf = GF_CALLOC (1, sizeof (struct stat), gf_meta_mt_stat);
ERR_ABORT (stbuf);
@@ -99,7 +100,7 @@ meta_dirent_t *
lookup_meta_entry (meta_dirent_t *root, const char *path,
char **remain)
{
- char *_path = strdup (path);
+ char *_path = gf_strdup (path);
if (!is_meta_path (path))
return NULL;
@@ -119,10 +120,10 @@ lookup_meta_entry (meta_dirent_t *root, const char *path,
while (piece) {
char *tmp = *remain;
if (*remain)
- asprintf (remain, "/%s/%s", *remain, piece);
+ gf_asprintf (remain, "/%s/%s", *remain, piece);
else
- asprintf (remain, "/%s", piece);
- if (tmp) free (tmp);
+ gf_asprintf (remain, "/%s", piece);
+ if (tmp) GF_FREE (tmp);
piece = strtok (NULL, "/");
}
}
@@ -132,7 +133,7 @@ lookup_meta_entry (meta_dirent_t *root, const char *path,
trav = ntrav;
}
- free (_path);
+ GF_FREE (_path);
return trav;
}
@@ -148,9 +149,10 @@ insert_meta_entry (meta_dirent_t *root, const char *path,
if (!dir)
return NULL;
- meta_dirent_t *new = CALLOC (1, sizeof (meta_dirent_t));
+ meta_dirent_t *new = GF_CALLOC (1, sizeof (meta_dirent_t),
+ gf_meta_mt_meta_dirent_t);
ERR_ABORT (new);
- new->name = strdup (slashpos+1);
+ new->name = gf_strdup (slashpos+1);
new->type = type;
new->parent = parent;
new->next = parent->children;
@@ -167,9 +169,10 @@ insert_meta_entry (meta_dirent_t *root, const char *path,
int main (void)
{
- meta_dirent_t *root = CALLOC (1, sizeof (meta_dirent_t));
+ meta_dirent_t *root = GF_CALLOC (1, sizeof (meta_dirent_t),
+ gf_meta_mt_meta_dirent_t);
ERR_ABORT (root);
- root->name = strdup (".meta");
+ root->name = gf_strdup (".meta");
insert_meta_entry (root, "/.meta/version", S_IFREG, NULL, NULL);
return 0;