diff options
Diffstat (limited to 'lib/libzpool/kernel.c')
-rw-r--r-- | lib/libzpool/kernel.c | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/libzpool/kernel.c b/lib/libzpool/kernel.c index 0559347e9..494e544ea 100644 --- a/lib/libzpool/kernel.c +++ b/lib/libzpool/kernel.c @@ -1107,25 +1107,27 @@ ksiddomain_rele(ksiddomain_t *ksid) umem_free(ksid, sizeof (ksiddomain_t)); } -/* - * Do not change the length of the returned string; it must be freed - * with strfree(). - */ char * -kmem_asprintf(const char *fmt, ...) +kmem_vasprintf(const char *fmt, va_list adx) { - int size; - va_list adx; - char *buf; + char *buf = NULL; + va_list adx_copy; - va_start(adx, fmt); - size = vsnprintf(NULL, 0, fmt, adx) + 1; - va_end(adx); + va_copy(adx_copy, adx); + VERIFY(vasprintf(&buf, fmt, adx_copy) != -1); + va_end(adx_copy); - buf = kmem_alloc(size, KM_SLEEP); + return (buf); +} + +char * +kmem_asprintf(const char *fmt, ...) +{ + char *buf = NULL; + va_list adx; va_start(adx, fmt); - size = vsnprintf(buf, size, fmt, adx); + VERIFY(vasprintf(&buf, fmt, adx) != -1); va_end(adx); return (buf); |