summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/mem-pool.c
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-10-02 07:30:38 +0000
committerVijay Bellur <vijay@dev.gluster.com>2010-10-02 06:30:18 -0700
commit067d0e476abe42f1e290039cb903928080e90d8d (patch)
tree2dfa9c04911ddedf283c5e4fac9ff9c41fb28ee6 /libglusterfs/src/mem-pool.c
parent1cc15f9b0057cd6c8843c8b9cbb36c02d334ec6f (diff)
implemented graph printing
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Vijay Bellur <vijay@dev.gluster.com> BUG: 1750 (clean up volgen) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1750
Diffstat (limited to 'libglusterfs/src/mem-pool.c')
-rw-r--r--libglusterfs/src/mem-pool.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/libglusterfs/src/mem-pool.c b/libglusterfs/src/mem-pool.c
index f266ce61f..1223b3711 100644
--- a/libglusterfs/src/mem-pool.c
+++ b/libglusterfs/src/mem-pool.c
@@ -197,9 +197,9 @@ __gf_realloc (void *ptr, size_t size)
}
int
-gf_asprintf (char **string_ptr, const char *format, ...)
+gf_vasprintf (char **string_ptr, const char *format, va_list arg)
{
- va_list arg;
+ va_list arg_save;
char *str = NULL;
int size = 0;
int rv = 0;
@@ -207,13 +207,12 @@ gf_asprintf (char **string_ptr, const char *format, ...)
if (!string_ptr || !format)
return -1;
- va_start (arg, format);
+ va_copy (arg_save, arg);
+
size = vsnprintf (NULL, 0, format, arg);
size++;
- va_start (arg, format);
str = GF_MALLOC (size, gf_common_mt_asprintf);
if (str == NULL) {
- va_end (arg);
/*
* Strictly speaking, GNU asprintf doesn't do this,
* but the caller isn't checking the return value.
@@ -222,13 +221,25 @@ gf_asprintf (char **string_ptr, const char *format, ...)
"failed to allocate memory");
return -1;
}
- rv = vsnprintf( str, size, format, arg);
- va_end (arg);
+ rv = vsnprintf (str, size, format, arg_save);
*string_ptr = str;
return (rv);
}
+int
+gf_asprintf (char **string_ptr, const char *format, ...)
+{
+ va_list arg;
+ int rv = 0;
+
+ va_start (arg, format);
+ rv = gf_vasprintf (string_ptr, format, arg);
+ va_end (arg);
+
+ return rv;
+}
+
void
__gf_free (void *free_ptr)
{