X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdata%2Fcase-matcher.c;h=e1ad48fde0853c7f1a477b8532ca4987fe7acbfc;hb=577812dc389ab344cc7ad83cc826f7066786b99b;hp=a1251cb74cbfd816c7dab2ed54129659a0215e0b;hpb=14aac9fe7a7efbb6c9bded2ed5969a643cb76645;p=pspp diff --git a/src/data/case-matcher.c b/src/data/case-matcher.c index a1251cb74c..e1ad48fde0 100644 --- a/src/data/case-matcher.c +++ b/src/data/case-matcher.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2008, 2009 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,16 +16,16 @@ #include -#include +#include "data/case-matcher.h" #include -#include -#include -#include -#include +#include "data/case.h" +#include "data/subcase.h" +#include "data/value.h" +#include "libpspp/assertion.h" -#include "xalloc.h" +#include "gl/xalloc.h" struct case_matcher_input { @@ -68,8 +68,11 @@ case_matcher_add_input (struct case_matcher *cm, const struct subcase *by, struct case_matcher_input *input; if (cm->n_inputs == 0) - cm->by_values = xmalloc (subcase_get_n_values (by) - * sizeof *cm->by_values); + { + cm->by_values = xmalloc (sizeof *cm->by_values + * subcase_get_n_fields (by)); + caseproto_init_values (subcase_get_proto (by), cm->by_values); + } else assert (subcase_conformable (by, &cm->inputs[0].by_vars)); @@ -90,10 +93,16 @@ case_matcher_destroy (struct case_matcher *cm) { size_t i; + if (cm->by_values != NULL) + { + caseproto_destroy_values (subcase_get_proto (&cm->inputs[0].by_vars), + cm->by_values); + free (cm->by_values); + } for (i = 0; i < cm->n_inputs; i++) { struct case_matcher_input *input = &cm->inputs[i]; - subcase_destroy (&input->by_vars); + subcase_uninit (&input->by_vars); } free (cm->inputs); free (cm);