ae35b8a7a1580ad873da25b62ffc2dc5bab95e22
[pspp-builds.git] / src / language / stats / freq.c
1 /* PSPP - computes sample statistics.
2    Copyright (C) 2006 Free Software Foundation, Inc.
3
4    This program is free software; you can redistribute it and/or
5    modify it under the terms of the GNU General Public License as
6    published by the Free Software Foundation; either version 2 of the
7    License, or (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful, but
10    WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program; if not, write to the Free Software
16    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17    02110-1301, USA. */
18
19 #include <config.h>
20 #include <data/variable.h>
21 #include <data/value.h>
22 #include <libpspp/compiler.h>
23
24 #include <stdlib.h>
25
26 #include "freq.h"
27
28 int
29 compare_freq ( const void *_f1, const void *_f2, const void *_var)
30 {
31   const struct freq *f1 = _f1;
32   const struct freq *f2 = _f2;
33   const struct variable *var = _var;
34
35   return  compare_values (f1->value, f2->value, var_get_width (var) );
36 }
37
38 unsigned int
39 hash_freq (const void *_f, const void *_var)
40 {
41   const struct freq *f = _f;
42   const struct variable *var  = _var;
43
44   return hash_value (f->value, var_get_width (var));
45 }
46
47 /* Free function to be used on FR whose value parameter has been copied */
48 void
49 free_freq_mutable_hash (void *fr, const void *var UNUSED)
50 {
51   struct freq_mutable *freq = fr;
52   free (freq->value);
53   free (freq);
54 }
55
56 void
57 free_freq_hash (void *fr, const void *var UNUSED)
58 {
59   free (fr);
60 }