projects
/
pspp
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ed17970
)
no leaks?
author
Ben Pfaff
<blp@cs.stanford.edu>
Thu, 4 Aug 2022 17:44:07 +0000
(10:44 -0700)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Thu, 4 Aug 2022 17:44:07 +0000
(10:44 -0700)
src/language/stats/ctables.c
patch
|
blob
|
history
diff --git
a/src/language/stats/ctables.c
b/src/language/stats/ctables.c
index e54be6d64bcfcb9d602438285945e8a41dad455e..5393c1b838b5343bc4eb71433c0246c130d26eac 100644
(file)
--- a/
src/language/stats/ctables.c
+++ b/
src/language/stats/ctables.c
@@
-854,6
+854,7
@@
ctables_summary_spec_set_uninit (struct ctables_summary_spec_set *set)
{
for (size_t i = 0; i < set->n; i++)
ctables_summary_spec_uninit (&set->specs[i]);
{
for (size_t i = 0; i < set->n; i++)
ctables_summary_spec_uninit (&set->specs[i]);
+ free (set->listwise_vars);
free (set->specs);
}
free (set->specs);
}
@@
-1730,7
+1731,10
@@
ctables_table_parse_explicit_category (struct lexer *lexer,
else
{
if (!lex_force_string (lexer))
else
{
if (!lex_force_string (lexer))
- return false;
+ {
+ ss_dealloc (&s);
+ return false;
+ }
struct substring sr1 = parse_substring (lexer, dict);
*cat = cct_srange (s, sr1);
}
struct substring sr1 = parse_substring (lexer, dict);
*cat = cct_srange (s, sr1);
}
@@
-2374,6
+2378,8
@@
ctables_nest_uninit (struct ctables_nest *nest)
free (nest->vars);
for (enum ctables_summary_variant sv = 0; sv < N_CSVS; sv++)
ctables_summary_spec_set_uninit (&nest->specs[sv]);
free (nest->vars);
for (enum ctables_summary_variant sv = 0; sv < N_CSVS; sv++)
ctables_summary_spec_set_uninit (&nest->specs[sv]);
+ for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
+ free (nest->domains[dt]);
}
static void
}
static void
@@
-2404,7
+2410,6
@@
nest_fts (struct ctables_stack s0, struct ctables_stack s1)
size_t allocate = a->n + b->n;
struct variable **vars = xnmalloc (allocate, sizeof *vars);
size_t allocate = a->n + b->n;
struct variable **vars = xnmalloc (allocate, sizeof *vars);
- enum pivot_axis_type *axes = xnmalloc (allocate, sizeof *axes);
size_t n = 0;
for (size_t k = 0; k < a->n; k++)
vars[n++] = a->vars[k];
size_t n = 0;
for (size_t k = 0; k < a->n; k++)
vars[n++] = a->vars[k];
@@
-5043,10
+5048,13
@@
ctables_prepare_table (struct ctables_table *t)
listwise_vars[n++] = other_nest->vars[other_nest->scale_idx];
}
}
listwise_vars[n++] = other_nest->vars[other_nest->scale_idx];
}
}
- for (
size_t j = 0; j < N_CSVS; j
++)
+ for (
enum ctables_summary_variant sv = 0; sv < N_CSVS; sv
++)
{
{
- nest->specs[j].listwise_vars = listwise_vars;
- nest->specs[j].n_listwise_vars = n;
+ if (sv > 0)
+ listwise_vars = xmemdup (listwise_vars,
+ n * sizeof *listwise_vars);
+ nest->specs[sv].listwise_vars = listwise_vars;
+ nest->specs[sv].n_listwise_vars = n;
}
}
}
}
}
}
@@
-5401,11
+5409,6
@@
ctables_section_uninit (struct ctables_section *s)
for (size_t i = 0; i < nest->n; i++)
hmap_destroy (&s->occurrences[a][i]);
free (s->occurrences[a]);
for (size_t i = 0; i < nest->n; i++)
hmap_destroy (&s->occurrences[a][i]);
free (s->occurrences[a]);
- for (enum ctables_domain_type dt = 0; dt < N_CTDTS; dt++)
- {
- free (nest->domains[dt]);
- nest->domains[dt] = NULL;
- }
}
hmap_destroy (&s->cells);
}
hmap_destroy (&s->cells);
@@
-5579,7
+5582,7
@@
struct operator
};
static const struct operator *
};
static const struct operator *
-ctable_pcexpr_match_operator (struct lexer *lexer,
+ctable
s
_pcexpr_match_operator (struct lexer *lexer,
const struct operator ops[], size_t n_ops)
{
for (const struct operator *op = ops; op < ops + n_ops; op++)
const struct operator ops[], size_t n_ops)
{
for (const struct operator *op = ops; op < ops + n_ops; op++)
@@
-5595,7
+5598,7
@@
ctable_pcexpr_match_operator (struct lexer *lexer,
}
static struct ctables_pcexpr *
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_binary_operators__ (
+ctable
s
_pcexpr_parse_binary_operators__ (
struct lexer *lexer, struct dictionary *dict,
const struct operator ops[], size_t n_ops,
parse_recursively_func *parse_next_level,
struct lexer *lexer, struct dictionary *dict,
const struct operator ops[], size_t n_ops,
parse_recursively_func *parse_next_level,
@@
-5604,7
+5607,7
@@
ctable_pcexpr_parse_binary_operators__ (
for (int op_count = 0; ; op_count++)
{
const struct operator *op
for (int op_count = 0; ; op_count++)
{
const struct operator *op
- = ctable_pcexpr_match_operator (lexer, ops, n_ops);
+ = ctable
s
_pcexpr_match_operator (lexer, ops, n_ops);
if (!op)
{
if (op_count > 1 && chain_warning)
if (!op)
{
if (op_count > 1 && chain_warning)
@@
-5625,23
+5628,22
@@
ctable_pcexpr_parse_binary_operators__ (
}
static struct ctables_pcexpr *
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_binary_operators (struct lexer *lexer,
- struct dictionary *dict,
- const struct operator ops[], size_t n_ops,
- parse_recursively_func *parse_next_level,
- const char *chain_warning)
+ctables_pcexpr_parse_binary_operators (
+ struct lexer *lexer, struct dictionary *dict,
+ const struct operator ops[], size_t n_ops,
+ parse_recursively_func *parse_next_level, const char *chain_warning)
{
struct ctables_pcexpr *lhs = parse_next_level (lexer, dict);
if (!lhs)
return NULL;
{
struct ctables_pcexpr *lhs = parse_next_level (lexer, dict);
if (!lhs)
return NULL;
- return ctable_pcexpr_parse_binary_operators__ (lexer, dict, ops, n_ops,
+ return ctable
s
_pcexpr_parse_binary_operators__ (lexer, dict, ops, n_ops,
parse_next_level,
chain_warning, lhs);
}
parse_next_level,
chain_warning, lhs);
}
-static struct ctables_pcexpr *ctable_pcexpr_parse_add (struct lexer *,
- struct dictionary *);
+static struct ctables_pcexpr *ctable
s
_pcexpr_parse_add (struct lexer *,
+
struct dictionary *);
static struct ctables_pcexpr
ctpo_cat_nrange (double low, double high)
static struct ctables_pcexpr
ctpo_cat_nrange (double low, double high)
@@
-5662,7
+5664,7
@@
ctpo_cat_srange (struct substring low, struct substring high)
}
static struct ctables_pcexpr *
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_primary (struct lexer *lexer, struct dictionary *dict)
+ctable
s
_pcexpr_parse_primary (struct lexer *lexer, struct dictionary *dict)
{
int start_ofs = lex_ofs (lexer);
struct ctables_pcexpr e;
{
int start_ofs = lex_ofs (lexer);
struct ctables_pcexpr e;
@@
-5779,7
+5781,7
@@
ctable_pcexpr_parse_primary (struct lexer *lexer, struct dictionary *dict)
}
else if (lex_match (lexer, T_LPAREN))
{
}
else if (lex_match (lexer, T_LPAREN))
{
- struct ctables_pcexpr *ep = ctable_pcexpr_parse_add (lexer, dict);
+ struct ctables_pcexpr *ep = ctable
s
_pcexpr_parse_add (lexer, dict);
if (!ep)
return NULL;
if (!lex_force_match (lexer, T_RPAREN))
if (!ep)
return NULL;
if (!lex_force_match (lexer, T_RPAREN))
@@
-5813,7
+5815,7
@@
ctables_pcexpr_allocate_neg (struct ctables_pcexpr *sub,
}
static struct ctables_pcexpr *
}
static struct ctables_pcexpr *
-ctable_pcexpr_parse_exp (struct lexer *lexer, struct dictionary *dict)
+ctable
s
_pcexpr_parse_exp (struct lexer *lexer, struct dictionary *dict)
{
static const struct operator op = { T_EXP, CTPO_POW };
{
static const struct operator op = { T_EXP, CTPO_POW };
@@
-5823,9
+5825,9
@@
ctable_pcexpr_parse_exp (struct lexer *lexer, struct dictionary *dict)
"To disable this warning, insert parentheses.");
if (lex_token (lexer) != T_NEG_NUM || lex_next_token (lexer, 1) != T_EXP)
"To disable this warning, insert parentheses.");
if (lex_token (lexer) != T_NEG_NUM || lex_next_token (lexer, 1) != T_EXP)
- return ctable_pcexpr_parse_binary_operators (lexer, dict, &op, 1,
-
ctable
_pcexpr_parse_primary,
- chain_warning);
+ return ctable
s
_pcexpr_parse_binary_operators (lexer, dict, &op, 1,
+
ctables
_pcexpr_parse_primary,
+
chain_warning);
/* Special case for situations like "-5**6", which must be parsed as
-(5**6). */
/* Special case for situations like "-5**6", which must be parsed as
-(5**6). */
@@
-5839,9
+5841,9
@@
ctable_pcexpr_parse_exp (struct lexer *lexer, struct dictionary *dict)
};
lex_get (lexer);
};
lex_get (lexer);
- struct ctables_pcexpr *node = ctable_pcexpr_parse_binary_operators__ (
+ struct ctables_pcexpr *node = ctable
s
_pcexpr_parse_binary_operators__ (
lexer, dict, &op, 1,
lexer, dict, &op, 1,
- ctable_pcexpr_parse_primary, chain_warning, lhs);
+ ctable
s
_pcexpr_parse_primary, chain_warning, lhs);
if (!node)
return NULL;
if (!node)
return NULL;
@@
-5850,13
+5852,13
@@
ctable_pcexpr_parse_exp (struct lexer *lexer, struct dictionary *dict)
/* Parses the unary minus level. */
static struct ctables_pcexpr *
/* Parses the unary minus level. */
static struct ctables_pcexpr *
-ctable_pcexpr_parse_neg (struct lexer *lexer, struct dictionary *dict)
+ctable
s
_pcexpr_parse_neg (struct lexer *lexer, struct dictionary *dict)
{
int start_ofs = lex_ofs (lexer);
if (!lex_match (lexer, T_DASH))
{
int start_ofs = lex_ofs (lexer);
if (!lex_match (lexer, T_DASH))
- return ctable_pcexpr_parse_exp (lexer, dict);
+ return ctable
s
_pcexpr_parse_exp (lexer, dict);
- struct ctables_pcexpr *inner = ctable_pcexpr_parse_neg (lexer, dict);
+ struct ctables_pcexpr *inner = ctable
s
_pcexpr_parse_neg (lexer, dict);
if (!inner)
return NULL;
if (!inner)
return NULL;
@@
-5865,7
+5867,7
@@
ctable_pcexpr_parse_neg (struct lexer *lexer, struct dictionary *dict)
/* Parses the multiplication and division level. */
static struct ctables_pcexpr *
/* Parses the multiplication and division level. */
static struct ctables_pcexpr *
-ctable_pcexpr_parse_mul (struct lexer *lexer, struct dictionary *dict)
+ctable
s
_pcexpr_parse_mul (struct lexer *lexer, struct dictionary *dict)
{
static const struct operator ops[] =
{
{
static const struct operator ops[] =
{
@@
-5873,14
+5875,14
@@
ctable_pcexpr_parse_mul (struct lexer *lexer, struct dictionary *dict)
{ T_SLASH, CTPO_DIV },
};
{ T_SLASH, CTPO_DIV },
};
- return ctable_pcexpr_parse_binary_operators (lexer, dict, ops,
+ return ctable
s
_pcexpr_parse_binary_operators (lexer, dict, ops,
sizeof ops / sizeof *ops,
sizeof ops / sizeof *ops,
- ctable_pcexpr_parse_neg, NULL);
+ ctable
s
_pcexpr_parse_neg, NULL);
}
/* Parses the addition and subtraction level. */
static struct ctables_pcexpr *
}
/* Parses the addition and subtraction level. */
static struct ctables_pcexpr *
-ctable_pcexpr_parse_add (struct lexer *lexer, struct dictionary *dict)
+ctable
s
_pcexpr_parse_add (struct lexer *lexer, struct dictionary *dict)
{
static const struct operator ops[] =
{
{
static const struct operator ops[] =
{
@@
-5889,9
+5891,9
@@
ctable_pcexpr_parse_add (struct lexer *lexer, struct dictionary *dict)
{ T_NEG_NUM, CTPO_ADD },
};
{ T_NEG_NUM, CTPO_ADD },
};
- return ctable_pcexpr_parse_binary_operators (lexer, dict,
+ return ctable
s
_pcexpr_parse_binary_operators (lexer, dict,
ops, sizeof ops / sizeof *ops,
ops, sizeof ops / sizeof *ops,
- ctable_pcexpr_parse_mul, NULL);
+ ctable
s
_pcexpr_parse_mul, NULL);
}
static struct ctables_postcompute *
}
static struct ctables_postcompute *
@@
-5931,10
+5933,11
@@
ctables_parse_pcompute (struct lexer *lexer, struct dictionary *dict,
}
int expr_start = lex_ofs (lexer);
}
int expr_start = lex_ofs (lexer);
- struct ctables_pcexpr *expr = ctable_pcexpr_parse_add (lexer, dict);
+ struct ctables_pcexpr *expr = ctable
s
_pcexpr_parse_add (lexer, dict);
int expr_end = lex_ofs (lexer) - 1;
if (!expr || !lex_force_match (lexer, T_RPAREN))
{
int expr_end = lex_ofs (lexer) - 1;
if (!expr || !lex_force_match (lexer, T_RPAREN))
{
+ ctables_pcexpr_destroy (expr);
free (name);
return false;
}
free (name);
return false;
}