summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/logging.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/logging.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/logging.c')
-rw-r--r--libglusterfs/src/logging.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c
index a006184cc..a8a7d4dc9 100644
--- a/libglusterfs/src/logging.c
+++ b/libglusterfs/src/logging.c
@@ -84,7 +84,7 @@ gf_log_init (const char *file)
pthread_mutex_init (&logfile_mutex, NULL);
- filename = strdup (file);
+ filename = gf_strdup (file);
if (!filename) {
fprintf (stderr, "gf_log_init: strdup error\n");
return -1;
@@ -153,11 +153,11 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
xlator_list_t * parent = NULL;
xlator_list_t * tmp = NULL;
- top = CALLOC (1, sizeof (*top));
+ top = GF_CALLOC (1, sizeof (*top), gf_common_mt_xlator_t);
if (!top)
goto out;
- trans = CALLOC (1, sizeof (*trans));
+ trans = GF_CALLOC (1, sizeof (*trans), gf_common_mt_xlator_t);
if (!trans)
goto out;
@@ -169,7 +169,8 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
top->next = trans;
top->init = dummy_init;
top->notify = gf_log_notify;
- top->children = (void *) CALLOC (1, sizeof (*top->children));
+ top->children = (void *) GF_CALLOC (1, sizeof (*top->children),
+ gf_common_mt_xlator_list_t);
if (!top->children)
goto out;
@@ -183,7 +184,7 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
trans->notify = default_notify;
trans->options = get_new_dict ();
- parent = CALLOC (1, sizeof(*parent));
+ parent = GF_CALLOC (1, sizeof(*parent), gf_common_mt_xlator_list_t);
if (!parent)
goto out;
@@ -219,7 +220,8 @@ __get_dummy_xlator (glusterfs_ctx_t *ctx, const char *remote_host,
ret = dict_set_static_ptr (trans->options, "non-blocking-io", "off");
if (transport) {
- char *transport_type = CALLOC (1, strlen (transport) + 10);
+ char *transport_type = GF_CALLOC (1, strlen (transport) + 10,
+ gf_common_mt_char);
ERR_ABORT (transport_type);
strcpy(transport_type, transport);
@@ -293,7 +295,7 @@ gf_log_central_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
msg = (struct _log_msg *) cookie;
- FREE (msg->msg);
+ GF_FREE ((char *)(msg->msg));
STACK_DESTROY (frame->root);
@@ -375,14 +377,14 @@ gf_log_central (const char *msg)
{
struct _log_msg *lm = NULL;
- lm = CALLOC (1, sizeof (*lm));
+ lm = GF_CALLOC (1, sizeof (*lm), gf_common_mt_log_msg);
if (!lm)
goto out;
INIT_LIST_HEAD (&lm->queue);
- lm->msg = strdup (msg);
+ lm->msg = gf_strdup (msg);
pthread_mutex_lock (&msg_queue_mutex);
{
@@ -491,10 +493,10 @@ log:
else
basename = file;
- ret = asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
- timestr, level_strings[level],
- basename, line, function,
- domain);
+ ret = gf_asprintf (&str1, "[%s] %s [%s:%d:%s] %s: ",
+ timestr, level_strings[level],
+ basename, line, function,
+ domain);
if (-1 == ret) {
goto unlock;
}
@@ -507,7 +509,7 @@ log:
va_end (ap);
len = strlen (str1);
- msg = malloc (len + strlen (str2) + 1);
+ msg = GF_MALLOC (len + strlen (str2) + 1, gf_common_mt_char);
strcpy (msg, str1);
strcpy (msg + len, str2);
@@ -528,11 +530,11 @@ unlock:
}
glusterfs_central_log_flag_unset ();
}
- FREE (msg);
+ GF_FREE (msg);
}
if (str1)
- FREE (str1);
+ GF_FREE (str1);
if (str2)
FREE (str2);
@@ -559,12 +561,12 @@ client_log_init (struct _client_log *cl, char *identifier)
cl->identifier = identifier;
- ret = asprintf (&path, "%s.client-%s", filename, identifier);
+ ret = gf_asprintf (&path, "%s.client-%s", filename, identifier);
if (-1 == ret) {
return;
}
cl->file = fopen (path, "a");
- FREE (path);
+ GF_FREE (path);
INIT_LIST_HEAD (&cl->list);
}
@@ -576,7 +578,8 @@ __logfile_for_client (char *identifier)
struct _client_log *client = NULL;
if (!client_logs) {
- client = CALLOC (1, sizeof (*client));
+ client = GF_CALLOC (1, sizeof (*client),
+ gf_common_mt_client_log);
client_log_init (client, identifier);
client_logs = client;
@@ -588,7 +591,8 @@ __logfile_for_client (char *identifier)
}
if (!client) {
- client = CALLOC (1, sizeof (*client));
+ client = GF_CALLOC (1, sizeof (*client),
+ gf_common_mt_client_log);
client_log_init (client, identifier);