X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Finteraction.c;h=4e4134f0ffcceb0b1ac79b5a8e0b583a3924be41;hb=aa2cd68fb42668614f168df3a319e48d009c3cc7;hp=d81eba5095b613231c5deef69d9e68f90c97ff27;hpb=bc414e71fa3378400ef3abf2c247c7f0bbac1b66;p=pspp diff --git a/src/math/interaction.c b/src/math/interaction.c index d81eba5095..4e4134f0ff 100644 --- a/src/math/interaction.c +++ b/src/math/interaction.c @@ -42,7 +42,6 @@ */ - struct interaction * interaction_create (const struct variable *v) { @@ -57,9 +56,30 @@ 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) { + if (NULL == i) + return; + free (i->vars); free (i); } @@ -152,10 +172,10 @@ interaction_to_string (const struct interaction *iact, struct string *str) } unsigned int -interaction_case_hash (const struct interaction *iact, const struct ccase *c) +interaction_case_hash (const struct interaction *iact, const struct ccase *c, unsigned int base) { int i; - size_t hash = 0; + size_t hash = base; for (i = 0; i < iact->n_vars; ++i) { const struct variable *var = iact->vars[i];