Index: trunk/Ohana/src/opihi/lib.shell/memstr.c
===================================================================
--- trunk/Ohana/src/opihi/lib.shell/memstr.c	(revision 4689)
+++ trunk/Ohana/src/opihi/lib.shell/memstr.c	(revision 4705)
@@ -1,4 +1,5 @@
 # include "shell.h"
 
+/* memstr returns a view, not an allocated string : don't free */
 /* returns pointer to start of m2 in m1, or NULL if failure */ 
 char *memstr (char *m1, char *m2, int n) {
@@ -12,2 +13,23 @@
 
 }
+
+/* formatted write statement, with intelligent allocation */
+int write_fmt (int fd, char *format, ...) {
+
+  int Nbyte, status;
+  char tmp, *line;
+  va_list argp;  
+
+  va_start (argp, format);
+  Nbyte = vsnprintf (&tmp, 0, format, argp);
+  va_end (argp);
+
+  va_start (argp, format);
+  ALLOCATE (line, char, Nbyte + 1);
+  vsnprintf (line, Nbyte + 1, format, argp);
+  status = write (fd, line, strlen(line));
+  va_end (argp);
+
+  free (line);
+  return (status);
+}
