summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/common-utils.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/common-utils.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/common-utils.c')
-rw-r--r--libglusterfs/src/common-utils.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 984ad0794a3..7851ad2f815 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -89,7 +89,8 @@ gf_resolve_ip6 (const char *hostname,
}
if (!*dnscache) {
- *dnscache = CALLOC (1, sizeof (struct dnscache6));
+ *dnscache = GF_CALLOC (1, sizeof (struct dnscache6),
+ gf_common_mt_dnscache6);
}
cache = *dnscache;
@@ -111,7 +112,7 @@ gf_resolve_ip6 (const char *hostname,
hints.ai_socktype = SOCK_STREAM;
hints.ai_flags = AI_ADDRCONFIG;
- ret = asprintf (&port_str, "%d", port);
+ ret = gf_asprintf (&port_str, "%d", port);
if (-1 == ret) {
gf_log ("resolver", GF_LOG_ERROR, "asprintf failed");
return -1;
@@ -120,12 +121,12 @@ gf_resolve_ip6 (const char *hostname,
gf_log ("resolver", GF_LOG_ERROR,
"getaddrinfo failed (%s)", gai_strerror (ret));
- free (*dnscache);
+ GF_FREE (*dnscache);
*dnscache = NULL;
- free (port_str);
+ GF_FREE (port_str);
return -1;
}
- free (port_str);
+ GF_FREE (port_str);
cache->next = cache->first;
}
@@ -173,7 +174,7 @@ gf_resolve_ip6 (const char *hostname,
err:
freeaddrinfo (cache->first);
cache->first = cache->next = NULL;
- free (cache);
+ GF_FREE (cache);
*dnscache = NULL;
return -1;
}
@@ -509,7 +510,8 @@ gf_strsplit (const char *str, const char *delim,
return -1;
}
- if ((_running = strdup (str)) == NULL)
+ _running = gf_strdup (str);
+ if (_running == NULL)
{
return -1;
}
@@ -520,17 +522,19 @@ gf_strsplit (const char *str, const char *delim,
if (token[0] != '\0')
count++;
}
- free (_running);
+ GF_FREE (_running);
- if ((_running = strdup (str)) == NULL)
+ _running = gf_strdup (str);
+ if (_running == NULL)
{
return -1;
}
running = _running;
- if ((token_list = CALLOC (count, sizeof (char *))) == NULL)
+ if ((token_list = GF_CALLOC (count, sizeof (char *),
+ gf_common_mt_char)) == NULL)
{
- free (_running);
+ GF_FREE (_running);
return -1;
}
@@ -539,23 +543,25 @@ gf_strsplit (const char *str, const char *delim,
if (token[0] == '\0')
continue;
- if ((token_list[i++] = strdup (token)) == NULL)
+ token_list[i] = gf_strdup (token);
+ if (token_list[i] == NULL)
goto free_exit;
+ i++;
}
- free (_running);
+ GF_FREE (_running);
*tokens = token_list;
*token_count = count;
return 0;
free_exit:
- free (_running);
+ GF_FREE (_running);
for (j = 0; j < i; j++)
{
- free (token_list[j]);
+ GF_FREE (token_list[j]);
}
- free (token_list);
+ GF_FREE (token_list);
return -1;
}