On 17/06/2016 18:33, Alex Bennée wrote: > @@ -807,18 +807,17 @@ int cpu_watchpoint_insert_with_ref(CPUState *cpu, vaddr > addr, vaddr len, > wp->flags = flags; > wp->ref = ref; > } else { > - wp = g_malloc(sizeof(*wp)); > - > - wp->vaddr = addr; > - wp->len = len; > - wp->flags = flags; > - wp->ref = ref; > + CPUWatchpoint watch; > + watch.vaddr = addr; > + watch.len = len; > + watch.flags = flags; > + watch.ref = ref; > > /* keep all GDB-injected watchpoints in front */ > if (flags & BP_GDB) { > - g_array_prepend_val(cpu->watchpoints, wp); > + g_array_prepend_val(cpu->watchpoints, watch); > } else { > - g_array_append_val(cpu->watchpoints, wp); > + g_array_append_val(cpu->watchpoints, watch); > }
Please define "watch" outside the "if", so that the "then" side can do just *wp = watch; and there is less duplication. Paolo