Added a function to clone an interaction.
[pspp-builds.git] / src / math / interaction.c
index 269aa7e9ad9af816a56b5c95d2fc4ce9ea90dbf7..4e4134f0ffcceb0b1ac79b5a8e0b583a3924be41 100644 (file)
@@ -42,7 +42,6 @@
 */
 
 
-
 struct interaction *
 interaction_create (const struct variable *v)
 {
@@ -57,6 +56,24 @@ interaction_create (const struct variable *v)
   return i;
 }
 
+/* Deep copy an interaction */
+struct interaction *
+interaction_clone (const struct interaction *iact)
+{
+  int v;
+  struct interaction  *i = xmalloc (sizeof *i);
+  i->vars = xcalloc (iact->n_vars, sizeof *i->vars);
+  i->n_vars = iact->n_vars;
+
+  for (v = 0; v < iact->n_vars; ++v)
+    {
+      i->vars[v] = iact->vars[v];
+    }
+
+  return i;
+}
+
+
 void
 interaction_destroy (struct interaction *i)
 {