X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fwilcoxon-sig.c;h=a9d9b70dbc9b94c5241365a2cf5580f5b78fd435;hb=2f3f4d9b20e0cde593fad4137cdc48922a38c3da;hp=a1b43dae506429f70833ddb2c9ae53f3356c707c;hpb=90a008db8b2f6e5bec903e584eb68e9bb20c061e;p=pspp diff --git a/src/math/wilcoxon-sig.c b/src/math/wilcoxon-sig.c index a1b43dae50..a9d9b70dbc 100644 --- a/src/math/wilcoxon-sig.c +++ b/src/math/wilcoxon-sig.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2009 Free Software Foundation, Inc. + Copyright (C) 2009, 2021 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 @@ -86,26 +86,26 @@ only 250,047. */ static unsigned long int -count_sums_to_W (unsigned long int n, unsigned long int w) +count_sums_to_W (unsigned long int n, long int w) { /* The array contain ints even though everything else is long, but no element in the array can have a value bigger than N, and using int will save some memory on 64-bit systems. */ unsigned long int total; unsigned long int max; - int *array; + assert (w >= 0); assert (n < CHAR_BIT * sizeof (unsigned long int)); if (n == 0) return 0; - else if (w <= 0) + else if (w == 0) return 1 << n; else if (w > n * (n + 1) / 2) return 0; else if (n == 1) return 1; - array = xcalloc (w + 1, sizeof *array); + int *array = XCALLOC (w + 1, int); array[w] = 1; max = w;