Separated the strings used for document tree generation from code
[biaweb2.git] / biawebutil.hpp
index 6a87827..c8603ea 100644 (file)
@@ -25,8 +25,8 @@ namespace biaweb {
         doc = mkd_string (str.c_str(), str.size(), 0);
         char tempfile[20];
         strcpy (tempfile, "/tmp/biawebXXXXXX");
-        mkstemp (tempfile);
-        FILE *f = fopen (tempfile, "w");
+        int fd = mkstemp (tempfile);
+        FILE *f = fdopen (fd, "w");
         markdown (doc, f, 0);
         fclose (f);
         std::ifstream ftmp (tempfile);
@@ -35,6 +35,7 @@ namespace biaweb {
                                 );
         ftmp.close ();
         mkd_cleanup (doc);
+        remove (tempfile);
         return tmpl;
     }