diff options
author | Jeremy Fitzhardinge <jeremy@goop.org> | 2007-04-30 15:09:56 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-04-30 16:40:40 -0700 |
commit | 11443ec7d9286dd25663516436a14edfb5f43857 (patch) | |
tree | 121137dbd7b323cd5dce71cbb8da8119a642b731 /lib | |
parent | 9684e51cd157607f0727c1550e7df6e31de40808 (diff) | |
download | op-kernel-dev-11443ec7d9286dd25663516436a14edfb5f43857.zip op-kernel-dev-11443ec7d9286dd25663516436a14edfb5f43857.tar.gz |
Add kvasprintf()
Add a kvasprintf() function to complement kasprintf().
No in-tree users yet, but I have some coming up.
[akpm@linux-foundation.org: EXPORT it]
Signed-off-by: Jeremy Fitzhardinge <jeremy@xensource.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Keir Fraser <keir@xensource.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/vsprintf.c | 26 |
1 files changed, 19 insertions, 7 deletions
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); |