On Wed, Aug 4, 2010 at 10:33 AM, Prerna Saxena <pre...@linux.vnet.ibm.com> wrote: > On 08/03/2010 07:45 PM, Stefan Hajnoczi wrote: >> On Tue, Aug 3, 2010 at 6:37 AM, Prerna Saxena<pre...@linux.vnet.ibm.com> >> wrote: >>> @@ -2590,6 +2597,12 @@ int main(int argc, char **argv, char **envp) >>> } >>> xen_mode = XEN_ATTACH; >>> break; >>> +#ifdef CONFIG_SIMPLE_TRACE >>> + case QEMU_OPTION_trace: >>> + trace_file = (char *) qemu_malloc(strlen(optarg) + 1); >>> + strcpy(trace_file, optarg); >>> + break; >>> +#endif >> >> Malloc isn't necessary, just hold the optarg pointer like gdbstub_dev >> and other string options do. > > It wouldnt be corect to use optarg directly here. If this optional argument > is not specified, st_set_file_name() is called with a NULL argument, and the > filename defaults to config-specified name. > (This is how gdbstub_dev works too. The optional argument is copied to > gdbstub_dev if provided.)
const char *trace_file = NULL; ... switch (...) { case QEMU_OPTION_trace: trace_file = optarg; break; } ... st_set_trace_file(trace_file); There is no need to malloc/strcpy/free. Stefan