driver: New function output_log_nocopy().
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 6 Dec 2021 05:16:29 +0000 (21:16 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 6 Dec 2021 05:23:58 +0000 (21:23 -0800)
src/language/expressions/evaluate.c
src/language/utilities/host.c
src/output/driver.c
src/output/driver.h

index 7543aed55e7ad29c167c9a5ee47c63b7d48660ec..d6d573848106b9fa8ca1bc8d4fc8ad9aa16659f4 100644 (file)
@@ -298,6 +298,5 @@ expr_debug_print_postfix (const struct expression *e)
           NOT_REACHED ();
         }
     }
-  output_log ("%s", ds_cstr (&s));
-  ds_destroy (&s);
+  output_log_nocopy (ds_steal_cstr (&s));
 }
index 477f9796a01ac519d91c684b78a3fa53032f7ff0..d730e02634860e4286a7ca245e45bc810394ed9a 100644 (file)
@@ -261,8 +261,7 @@ run_command (const char *command, struct timespec timeout)
       if (end > output && end[-1] == '\n')
         end[-1] = '\0';
 
-      output_log ("%s", output);
-      free (output);
+      output_log_nocopy (output);
     }
   free (locale_output);
 
index 063ae9366bf119697c97f9da780b85d68649c279..f627e31248d69c1398739bd369307ec94dcd86fc 100644 (file)
@@ -366,6 +366,12 @@ output_log (const char *format, ...)
   char *s = xvasprintf (format, args);
   va_end (args);
 
+  output_log_nocopy (s);
+}
+
+void
+output_log_nocopy (char *s)
+{
   output_submit (text_item_create_nocopy (TEXT_ITEM_LOG, s, NULL));
 }
 
index 3e5cf193a4bdb9fcddc80b17bbd478ef9c405185..c16774dd99cdf3857926769bb012e1807a6d5090 100644 (file)
@@ -35,6 +35,7 @@ void output_submit (struct output_item *);
 void output_flush (void);
 
 void output_log (const char *, ...) PRINTF_FORMAT (1, 2);
+void output_log_nocopy (char *);
 
 const char *output_get_title (void);
 void output_set_title (const char *);