The gnulib xcalloc call has the following signature:
void *calloc(size_t N, size_t S);
where N is the number of objects and S is the size of each object.
In many places, we had these arguments transposed. In many implementations
this doesn't matter since the two arguments are simply multiplied together.
However, on some systems this can cause problems (ie crash), if S is zero.
This change fixes all calls where the size was being passes as the first
argument instead of the second.
13 files changed:
int v;
struct casereader *r = casereader_clone (input);
int v;
struct casereader *r = casereader_clone (input);
- struct ks *ks = xcalloc (sizeof *ks, ost->n_vars);
+ struct ks *ks = xcalloc (ost->n_vars, sizeof *ks);
for (v = 0; v < ost->n_vars; ++v)
{
for (v = 0; v < ost->n_vars; ++v)
{
struct casereader *r = input;
struct casereader *r = input;
- struct mcnemar *mc = xcalloc (sizeof *mc, t2s->n_pairs);
+ struct mcnemar *mc = xcalloc (t2s->n_pairs, sizeof *mc);
for (i = 0 ; i < t2s->n_pairs; ++i )
{
for (i = 0 ; i < t2s->n_pairs; ++i )
{
const struct two_sample_test *t2s = UP_CAST (test, const struct two_sample_test, parent);
struct ccase *c;
const struct two_sample_test *t2s = UP_CAST (test, const struct two_sample_test, parent);
struct ccase *c;
- struct sign_test_params *stp = xcalloc (sizeof *stp, t2s->n_pairs);
+ struct sign_test_params *stp = xcalloc (t2s->n_pairs, sizeof *stp);
struct casereader *r = input;
struct casereader *r = input;
struct ccase *c;
struct casereader *r;
struct ccase *c;
struct casereader *r;
- struct pair_stats *ps = xcalloc (sizeof (*ps), tt->n_vars);
+ struct pair_stats *ps = xcalloc (tt->n_vars, sizeof *ps);
else
n_pairs = n_v1 * n_v2;
else
n_pairs = n_v1 * n_v2;
- pairs = xcalloc (sizeof *pairs, n_pairs);
-
+ pairs = xcalloc (n_pairs, sizeof *pairs);
const struct dictionary *dict = dataset_dict (ds);
const struct two_sample_test *t2s = UP_CAST (test, const struct two_sample_test, parent);
const struct dictionary *dict = dataset_dict (ds);
const struct two_sample_test *t2s = UP_CAST (test, const struct two_sample_test, parent);
- struct wilcoxon_state *ws = xcalloc (sizeof (*ws), t2s->n_pairs);
+ struct wilcoxon_state *ws = xcalloc (t2s->n_pairs, sizeof *ws);
const struct variable *weight = dict_get_weight (dict);
struct variable *weightx = dict_create_internal_var (WEIGHT_IDX, 0);
struct caseproto *proto;
const struct variable *weight = dict_get_weight (dict);
struct variable *weightx = dict_create_internal_var (WEIGHT_IDX, 0);
struct caseproto *proto;
cov->n_cm = (n_vars * (n_vars - 1) ) / 2;
cov->n_cm = (n_vars * (n_vars - 1) ) / 2;
- if (cov->n_cm > 0)
- cov->cm = xcalloc (sizeof *cov->cm, cov->n_cm);
+
+ cov->cm = xcalloc (cov->n_cm, sizeof *cov->cm);
cov->categoricals = NULL;
return cov;
cov->categoricals = NULL;
return cov;
- os->k = xcalloc (sizeof (*os->k), 2);
+ os->k = xcalloc (2, sizeof (*os->k));
os->k[0].tc = W * p;
os->k[1].tc = (W + 1.0) * p;
os->k[0].tc = W * p;
os->k[1].tc = (W + 1.0) * p;
struct statistic *stat = &os->parent;
os->n_k = 2;
struct statistic *stat = &os->parent;
os->n_k = 2;
- os->k = xcalloc (sizeof (*os->k), 2);
+ os->k = xcalloc (2, sizeof (*os->k));
assert (tail >= 0);
assert (tail <= 1);
assert (tail >= 0);
assert (tail <= 1);
assert (c_min >= 0);
os->n_k = 3;
assert (c_min >= 0);
os->n_k = 3;
- os->k = xcalloc (sizeof (*os->k), 3);
+ os->k = xcalloc (3, sizeof (*os->k));
else if (n == 1)
return 1;
else if (n == 1)
return 1;
- array = xcalloc (sizeof *array, w + 1);
+ array = xcalloc (w + 1, sizeof *array);
g_return_if_fail (0 == printf_parse (scanf->format, &scanf->d, &a));
if ( scanf->d.count > 0)
g_return_if_fail (0 == printf_parse (scanf->format, &scanf->d, &a));
if ( scanf->d.count > 0)
- scanf->widgets = xcalloc (sizeof (*scanf->widgets), scanf->d.count);
+ scanf->widgets = xcalloc (scanf->d.count, sizeof (*scanf->widgets));
/* A is not used, so get rid of it */
if (a.arg != a.direct_alloc_arg)
/* A is not used, so get rid of it */
if (a.arg != a.direct_alloc_arg)
if ( 0 != printf_parse (fmt, &d, &a) )
return NULL;
if ( 0 != printf_parse (fmt, &d, &a) )
return NULL;
- widgets = xcalloc (sizeof (*widgets), d.count);
+ widgets = xcalloc (d.count, sizeof (*widgets));
va_start (ap, fmt);
for (i = 0 ; i < d.count ; ++i )
{
va_start (ap, fmt);
for (i = 0 ; i < d.count ; ++i )
{