Patchwork [-V3,24/32] qemu-malloc: Add qemu_asprintf

login
register
mail settings
Submitter Aneesh Kumar K.V
Date March 25, 2010, 4:43 p.m.
Message ID <1269535420-31206-25-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
Download mbox | patch
Permalink /patch/48578/
State New
Headers show

Comments

Aneesh Kumar K.V - March 25, 2010, 4:43 p.m.
From: Gautham R Shenoy <ego@in.ibm.com>

Add the API qemu_asprintf() along the lines of qemu_vasprintf()

Signed-off-by: Gautham R Shenoy <ego@in.ibm.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 qemu-common.h |    1 +
 qemu-malloc.c |   12 ++++++++++++
 2 files changed, 13 insertions(+), 0 deletions(-)

Patch

diff --git a/qemu-common.h b/qemu-common.h
index 6e925ab..f597f27 100644
--- a/qemu-common.h
+++ b/qemu-common.h
@@ -161,6 +161,7 @@  void qemu_free(void *ptr);
 char *qemu_strdup(const char *str);
 char *qemu_strndup(const char *str, size_t size);
 int qemu_vasprintf(char **strp, const char *fmt, va_list ap);
+int qemu_asprintf(char **strp, const char *fmt, ...);
 
 void *get_mmap_addr(unsigned long size);
 
diff --git a/qemu-malloc.c b/qemu-malloc.c
index d6de067..9bfefb4 100644
--- a/qemu-malloc.c
+++ b/qemu-malloc.c
@@ -103,3 +103,15 @@  int qemu_vasprintf(char **strp, const char *fmt, va_list ap)
 {
     return vasprintf(strp, fmt, ap);
 }
+
+int qemu_asprintf(char **strp, const char *fmt, ...)
+{
+    va_list ap;
+    int err;
+
+    va_start(ap, fmt);
+    err = qemu_vasprintf(strp, fmt, ap);
+    va_end(ap);
+
+    return err;
+}