Avoid use of vasprintf.
authorVincent Povirk <vincent@codeweavers.com>
Mon, 8 Sep 2014 20:46:12 +0000 (15:46 -0500)
committerVincent Povirk <vincent@codeweavers.com>
Mon, 8 Sep 2014 20:48:20 +0000 (15:48 -0500)
This is not available on mingw-w64, and the extra allocation is unnecessary.

This commit licensed as MIT/X11.

mono/mini/aot-compiler.c

index 5f388de76e8d94ecb7d8f2c1d6f075be70517a39..e54fc05083e9a4cabebbb5659899343041712a6d 100644 (file)
@@ -308,39 +308,33 @@ get_plt_entry_debug_sym (MonoAotCompile *acfg, MonoJumpInfo *ji, GHashTable *cac
 static void
 aot_printf (MonoAotCompile *acfg, const gchar *format, ...)
 {
-       char *msg;
+       FILE *output;
        va_list args;
 
-       va_start (args, format);
-       if (vasprintf (&msg, format, args) < 0)
-               return;
-       va_end (args);
-
        if (acfg->logfile)
-               fprintf (acfg->logfile, "%s", msg);
+               output = acfg->logfile;
        else
-               printf ("%s", msg);
+               output = stdout;
 
-       free (msg);
+       va_start (args, format);
+       vfprintf (output, format, args);
+       va_end (args);
 }
 
 static void
 aot_printerrf (MonoAotCompile *acfg, const gchar *format, ...)
 {
-       char *msg;
+       FILE *output;
        va_list args;
 
-       va_start (args, format);
-       if (vasprintf (&msg, format, args) < 0)
-               return;
-       va_end (args);
-
        if (acfg->logfile)
-               fprintf (acfg->logfile, "%s", msg);
+               output = acfg->logfile;
        else
-               fprintf (stderr, "%s", msg);
+               output = stderr;
 
-       free (msg);
+       va_start (args, format);
+       vfprintf (output, format, args);
+       va_end (args);
 }
 
 /* Wrappers around the image writer functions */