projects
/
pspp-builds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
GLM: Fix memory leaks
[pspp-builds.git]
/
src
/
math
/
categoricals.c
diff --git
a/src/math/categoricals.c
b/src/math/categoricals.c
index 16bb46f6a1cbc72601c8e70b5e44c2f04508898f..a3078d36384208024f92379c41e5b6a3dd85344f 100644
(file)
--- a/
src/math/categoricals.c
+++ b/
src/math/categoricals.c
@@
-48,7
+48,6
@@
struct var_params
/* A map indexed by a union values */
struct hmap map;
/* A map indexed by a union values */
struct hmap map;
- const struct variable *var;
const struct interaction *iact;
int base_subscript_short;
const struct interaction *iact;
int base_subscript_short;
@@
-82,7
+81,6
@@
struct categoricals
/* The weight variable */
const struct variable *wv;
/* The weight variable */
const struct variable *wv;
-
/* An array of var_params */
struct var_params *vp;
/* An array of var_params */
struct var_params *vp;
@@
-127,7
+125,17
@@
categoricals_destroy ( struct categoricals *cat)
if (cat != NULL)
{
for (i = 0 ; i < cat->n_vp; ++i)
if (cat != NULL)
{
for (i = 0 ; i < cat->n_vp; ++i)
- hmap_destroy (&cat->vp[i].map);
+ {
+ struct hmap *map = &cat->vp[i].map;
+ struct value_node *nn;
+
+ HMAP_FOR_EACH (nn, struct value_node, node, map)
+ {
+ case_unref (nn->ccase);
+ }
+
+ hmap_destroy (map);
+ }
pool_destroy (cat->pool);
free (cat);
pool_destroy (cat->pool);
free (cat);
@@
-244,7
+252,6
@@
categoricals_create (const struct interaction **inter, size_t n_inter,
for (i = 0 ; i < cat->n_vp; ++i)
{
hmap_init (&cat->vp[i].map);
for (i = 0 ; i < cat->n_vp; ++i)
{
hmap_init (&cat->vp[i].map);
- cat->vp[i].var = inter[i]->vars[0];
cat->vp[i].iact = inter[i];
}
cat->vp[i].iact = inter[i];
}
@@
-266,23
+273,17
@@
categoricals_update (struct categoricals *cat, const struct ccase *c)
for (i = 0 ; i < cat->n_vp; ++i)
{
const struct interaction *iact = cat->vp[i].iact;
for (i = 0 ; i < cat->n_vp; ++i)
{
const struct interaction *iact = cat->vp[i].iact;
- const struct variable *var = cat->vp[i].var;
-
- const union value *val = case_data (c, var);
size_t hash;
struct value_node *node ;
size_t hash;
struct value_node *node ;
-#if XXX
- if ( var_is_value_missing (var, val, cat->exclude))
+ if ( interaction_case_is_missing (iact, c, cat->exclude))
continue;
continue;
-#endif
hash = interaction_case_hash (iact, c);
node = lookup_case (&cat->vp[i].map, iact, c);
if ( NULL == node)
{
hash = interaction_case_hash (iact, c);
node = lookup_case (&cat->vp[i].map, iact, c);
if ( NULL == node)
{
- int width = var_get_width (var);
node = pool_malloc (cat->pool, sizeof *node);
node->ccase = case_ref (c);
node = pool_malloc (cat->pool, sizeof *node);
node->ccase = case_ref (c);
@@
-304,7
+305,7
@@
categoricals_update (struct categoricals *cat, const struct ccase *c)
cat->vp[i].cc += weight;
if (cat->update)
cat->vp[i].cc += weight;
if (cat->update)
- cat->update (node->user_data, cat->exclude, cat->wv,
var
, c, cat->aux1, cat->aux2);
+ cat->update (node->user_data, cat->exclude, cat->wv,
NULL
, c, cat->aux1, cat->aux2);
}
}
}
}
@@
-409,11
+410,11
@@
categoricals_get_variable_by_subscript (const struct categoricals *cat, int subs
{
int index = reverse_variable_lookup_short (cat, subscript);
{
int index = reverse_variable_lookup_short (cat, subscript);
- return cat->vp[index].
var
;
+ return cat->vp[index].
iact->vars[0]
;
}
/* Return the interaction corresponding to SUBSCRIPT */
}
/* Return the interaction corresponding to SUBSCRIPT */
-
static
const struct interaction *
+const struct interaction *
categoricals_get_interaction_by_subscript (const struct categoricals *cat, int subscript)
{
int index = reverse_variable_lookup_short (cat, subscript);
categoricals_get_interaction_by_subscript (const struct categoricals *cat, int subscript)
{
int index = reverse_variable_lookup_short (cat, subscript);