use plan9 malloc
diff --git a/src/lib9/fmt/fmtdef.h b/src/lib9/fmt/fmtdef.h
index ca2010a..8946876 100644
--- a/src/lib9/fmt/fmtdef.h
+++ b/src/lib9/fmt/fmtdef.h
@@ -25,7 +25,9 @@
 #define vlong _fmtvlong
 #define uvlong _fmtuvlong
 
+#ifndef USED
 #define USED(x) if(x);else
+#endif
 
 typedef unsigned char		uchar;
 typedef unsigned short		ushort;
@@ -37,6 +39,7 @@
 typedef long long		vlong;
 #endif
 
+#undef nil
 #define nil		0	/* cannot be ((void*)0) because used for function pointers */
 
 typedef int (*Fmts)(Fmt*);
diff --git a/src/lib9/fmt/fmtstr.c b/src/lib9/fmt/fmtstr.c
index 7af1fa2..0b22716 100644
--- a/src/lib9/fmt/fmtstr.c
+++ b/src/lib9/fmt/fmtstr.c
@@ -11,11 +11,8 @@
  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include "utf.h"
-#include "fmt.h"
+#include <u.h>
+#include <libc.h>
 #include "fmtdef.h"
 
 static int
diff --git a/src/lib9/fmt/runefmtstr.c b/src/lib9/fmt/runefmtstr.c
index a2ec6cb..9ec84cd 100644
--- a/src/lib9/fmt/runefmtstr.c
+++ b/src/lib9/fmt/runefmtstr.c
@@ -11,11 +11,8 @@
  * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
  * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
  */
-#include <stdarg.h>
-#include <string.h>
-#include <stdlib.h>
-#include "utf.h"
-#include "fmt.h"
+#include <u.h>
+#include <libc.h>
 #include "fmtdef.h"
 
 static int
diff --git a/src/lib9/fmt/vsmprint.c b/src/lib9/fmt/vsmprint.c
index 38ace62..34a1b36 100644
--- a/src/lib9/fmt/vsmprint.c
+++ b/src/lib9/fmt/vsmprint.c
@@ -31,6 +31,5 @@
 	n = dofmt(&f, fmt);
 	if(n < 0)
 		return nil;
-	*(char*)f.to = '\0';
-	return (char*)f.start;
+	return fmtstrflush(&f);
 }