X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmath%2Fcategoricals.c;h=fdd552fed58d3c08d7a95d27f471ef9257296f69;hb=33790599fcfd2de8553568801791b78704aae4de;hp=2bc2b626b0636c36c59a77fe0fb290738b87ead5;hpb=e0bcf133ab9091a2fa5227d2767651d8ec58caef;p=pspp diff --git a/src/math/categoricals.c b/src/math/categoricals.c index 2bc2b626b0..fdd552fed5 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -96,10 +96,10 @@ lookup_variable (const struct hmap *map, const struct variable *var, unsigned in struct interact_params { - /* A map indexed by a interaction_value */ + /* A map of cases indexed by a interaction_value */ struct hmap ivmap; - const struct interaction *iact; + struct interaction *iact; int base_subscript_short; int base_subscript_long; @@ -253,10 +253,8 @@ categoricals_destroy (struct categoricals *cat) /* Interate over each interaction value, and unref any cases that we reffed */ HMAP_FOR_EACH (iv, struct interaction_value, node, &cat->iap[i].ivmap) { -#if 0 - if (cat->payload) - cat->payload->destroy (cat->aux1, iv->user_data); -#endif + if (cat->payload && cat->payload->destroy) + cat->payload->destroy (cat->aux1, cat->aux2, iv->user_data); case_unref (iv->ccase); } @@ -360,6 +358,10 @@ categoricals_update (struct categoricals *cat, const struct ccase *c) { int i; struct variable_node *vn = NULL; + + if (NULL == cat) + return; + const double weight = cat->wv ? case_data (c, cat->wv)->f : 1.0; assert (NULL == cat->reverse_variable_map_short); @@ -455,6 +457,9 @@ categoricals_n_total (const struct categoricals *cat) size_t categoricals_df_total (const struct categoricals *cat) { + if (NULL == cat) + return 0; + return cat->df_sum; } @@ -481,6 +486,10 @@ categoricals_done (const struct categoricals *cat_) int i; int idx_short = 0; int idx_long = 0; + + if (NULL == cat) + return; + cat->df_sum = 0; cat->n_cats_total = 0; @@ -544,7 +553,6 @@ categoricals_done (const struct categoricals *cat_) HMAP_FOR_EACH (ivn, struct interaction_value, node, &iap->ivmap) { iap->reverse_interaction_value_map[x++] = ivn; - } assert (x <= iap->n_cats);