+static LttvCPUState *lttv_state_copy_cpu_states(LttvCPUState *states, guint n)
+{
+ guint i,j;
+ LttvCPUState *retval;
+
+ retval = g_malloc(n*sizeof(LttvCPUState));
+
+ for(i=0; i<n; i++) {
+ retval[i].mode_stack = g_array_new(FALSE, FALSE, sizeof(LttvCPUMode));
+ retval[i].last_irq = states[i].last_irq;
+ g_array_set_size(retval[i].mode_stack, states[i].mode_stack->len);
+ for(j=0; j<states[i].mode_stack->len; j++) {
+ g_array_index(retval[i].mode_stack, GQuark, j) = g_array_index(states[i].mode_stack, GQuark, j);
+ }
+ }
+
+ return retval;
+}
+
+static void lttv_state_free_cpu_states(LttvCPUState *states, guint n)
+{
+ guint i;
+
+ for(i=0; i<n; i++) {
+ g_array_free(states[i].mode_stack, FALSE);
+ }
+
+ g_free(states);
+}