struct psi_num_exp *cond, struct psi_num_exp *truthy,
struct psi_num_exp *falsy)
{
- struct psi_num_exp *exp = calloc(1, sizeof(*exp));
+ struct psi_num_exp *exp = pecalloc(1, sizeof(*exp), 1);
exp->op = op;
exp->data.t.cond = cond;
struct psi_num_exp *psi_num_exp_init_binary(token_t op,
struct psi_num_exp *lhs, struct psi_num_exp *rhs)
{
- struct psi_num_exp *exp = calloc(1, sizeof(*exp));
+ struct psi_num_exp *exp = pecalloc(1, sizeof(*exp), 1);
exp->op = op;
exp->data.b.lhs = lhs;
struct psi_num_exp *psi_num_exp_init_unary(token_t op,
struct psi_num_exp *u)
{
- struct psi_num_exp *exp = calloc(1, sizeof(*exp));
+ struct psi_num_exp *exp = pecalloc(1, sizeof(*exp), 1);
exp->op = op;
exp->data.u = u;
struct psi_num_exp *psi_num_exp_init_num(struct psi_number *n)
{
- struct psi_num_exp *exp = calloc(1, sizeof(*exp));
+ struct psi_num_exp *exp = pecalloc(1, sizeof(*exp), 1);
exp->op = PSI_T_NUMBER;
exp->data.n = n;
struct psi_num_exp *psi_num_exp_init_cast(struct psi_decl_type *typ,
struct psi_num_exp *num)
{
- struct psi_num_exp *exp = calloc(1, sizeof(*exp));
+ struct psi_num_exp *exp = pecalloc(1, sizeof(*exp), 1);
exp->op = PSI_T_CAST;
exp->data.c.typ = typ;
return NULL;
}
- cpy = malloc(sizeof(*cpy));
+ cpy = pemalloc(sizeof(*cpy), 1);
*cpy = *exp;
switch (exp->op) {
assert(0);
}
- if (c->token) {
- free(c->token);
- }
+ psi_token_free(&c->token);
free(c);
}
list = psi_plist_add(list, &ntoken);
ntoken = psi_token_copy(exp->data.c.typ->token);
list = psi_plist_add(list, &ntoken);
- ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
break;
list = psi_plist_add(list, &ntoken);
list = psi_num_exp_tokens(exp->data.u, list);
psi_plist_top(list, &ntoken);
- ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_RPAREN, ")", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
break;
list = psi_plist_add(list, &ntoken);
list = psi_num_exp_tokens(exp->data.t.truthy, list);
psi_plist_top(list, &ntoken);
- ntoken = psi_token_init(PSI_T_COLON, ":", 1, ntoken->col+ntoken->size, ntoken->line, ntoken->file);
+ ntoken = psi_token_init(PSI_T_COLON, ":", 1, ntoken->col+ntoken->text->len, ntoken->line, ntoken->file);
list = psi_plist_add(list, &ntoken);
list = psi_plist_add(list, &ntoken);
list = psi_num_exp_tokens(exp->data.t.falsy, list);