Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=11443ec7d9286dd25663516436a14edfb5f43857
Commit:     11443ec7d9286dd25663516436a14edfb5f43857
Parent:     9684e51cd157607f0727c1550e7df6e31de40808
Author:     Jeremy Fitzhardinge <[EMAIL PROTECTED]>
AuthorDate: Mon Apr 30 15:09:56 2007 -0700
Committer:  Linus Torvalds <[EMAIL PROTECTED]>
CommitDate: Mon Apr 30 16:40:40 2007 -0700

    Add kvasprintf()
    
    Add a kvasprintf() function to complement kasprintf().
    
    No in-tree users yet, but I have some coming up.
    
    [EMAIL PROTECTED]: EXPORT it]
    Signed-off-by: Jeremy Fitzhardinge <[EMAIL PROTECTED]>
    Cc: Andrew Morton <[EMAIL PROTECTED]>
    Cc: Keir Fraser <[EMAIL PROTECTED]>
    Signed-off-by: Andrew Morton <[EMAIL PROTECTED]>
    Signed-off-by: Linus Torvalds <[EMAIL PROTECTED]>
---
 include/linux/kernel.h |    1 +
 lib/vsprintf.c         |   26 +++++++++++++++++++-------
 2 files changed, 20 insertions(+), 7 deletions(-)

diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 9ddf25c..e2f41b0 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -121,6 +121,7 @@ extern int vscnprintf(char *buf, size_t size, const char 
*fmt, va_list args)
        __attribute__ ((format (printf, 3, 0)));
 extern char *kasprintf(gfp_t gfp, const char *fmt, ...)
        __attribute__ ((format (printf, 2, 3)));
+extern char *kvasprintf(gfp_t gfp, const char *fmt, va_list args);
 
 extern int sscanf(const char *, const char *, ...)
        __attribute__ ((format (scanf, 2, 3)));
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index b025864..cbab1df 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -851,23 +851,35 @@ EXPORT_SYMBOL(sscanf);
 
 
 /* Simplified asprintf. */
-char *kasprintf(gfp_t gfp, const char *fmt, ...)
+char *kvasprintf(gfp_t gfp, const char *fmt, va_list ap)
 {
-       va_list ap;
        unsigned int len;
        char *p;
+       va_list aq;
 
-       va_start(ap, fmt);
-       len = vsnprintf(NULL, 0, fmt, ap);
-       va_end(ap);
+       va_copy(aq, ap);
+       len = vsnprintf(NULL, 0, fmt, aq);
+       va_end(aq);
 
        p = kmalloc(len+1, gfp);
        if (!p)
                return NULL;
-       va_start(ap, fmt);
+
        vsnprintf(p, len+1, fmt, ap);
-       va_end(ap);
+
        return p;
 }
+EXPORT_SYMBOL(kvasprintf);
+
+char *kasprintf(gfp_t gfp, const char *fmt, ...)
+{
+       va_list ap;
+       char *p;
 
+       va_start(ap, fmt);
+       p = kvasprintf(gfp, fmt, ap);
+       va_end(ap);
+
+       return p;
+}
 EXPORT_SYMBOL(kasprintf);
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to