summaryrefslogtreecommitdiffstats
path: root/lib/libzpool/kernel.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2010-08-26 11:46:09 -0700
committerBrian Behlendorf <[email protected]>2010-08-31 13:41:57 -0700
commit00b46022c676e402e3f33ce93ee2983bbad2c46f (patch)
tree2204630c7abd1784f261df17cec4cd084747042f /lib/libzpool/kernel.c
parent60101509ee73c6e61e50c0a4079097f31bb39f4b (diff)
Add linux kernel memory support
Required kmem/vmem changes Signed-off-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'lib/libzpool/kernel.c')
-rw-r--r--lib/libzpool/kernel.c28
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);