From e0c2b55526074967dc11fd25183a464e4752e571 Mon Sep 17 00:00:00 2001 From: John Darrington Date: Sun, 18 Oct 2009 21:57:42 +0200 Subject: [PATCH] Fix order of pool_calloc arguments. The second argument is the number of elements, the third is the size. If this is inadvertently reversed, then it fails when the number of elements is zero. --- src/math/categoricals.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/math/categoricals.c b/src/math/categoricals.c index e4feda28..033b6a18 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -153,7 +153,7 @@ categoricals_create (const struct variable **v, size_t n_vars, const struct vari cat->reverse_variable_map = NULL; cat->pool = pool_create (); - cat->vp = pool_calloc (cat->pool, sizeof *cat->vp, n_vars); + cat->vp = pool_calloc (cat->pool, n_vars, sizeof *cat->vp); for (i = 0 ; i < cat->n_vars; ++i) hmap_init (&cat->vp[i].map); @@ -181,7 +181,7 @@ categoricals_update (struct categoricals *cat, const struct ccase *c) struct value_node *node = lookup_value (&cat->vp[i].map, cat->vars[i], val); if ( NULL == node) { - node = pool_calloc (cat->pool, sizeof *node, 1); + node = pool_malloc (cat->pool, sizeof *node); value_init (&node->value, width); value_copy (&node->value, val, width); @@ -238,7 +238,7 @@ categoricals_done (struct categoricals *cat) */ int v; int idx = 0; - cat->reverse_variable_map = pool_calloc (cat->pool, sizeof *cat->reverse_variable_map, cat->n_cats_total); + cat->reverse_variable_map = pool_calloc (cat->pool, cat->n_cats_total, sizeof *cat->reverse_variable_map); for (v = 0 ; v < cat->n_vars; ++v) { @@ -247,7 +247,7 @@ categoricals_done (struct categoricals *cat) int n_cats_total = categoricals_n_count (cat, v); struct hmap_node *node ; - vp->reverse_value_map = pool_calloc (cat->pool, sizeof *vp->reverse_value_map, n_cats_total); + vp->reverse_value_map = pool_calloc (cat->pool, n_cats_total, sizeof *vp->reverse_value_map); vp->base_subscript = idx; -- 2.30.2