Closed memory leak.

This commit is contained in:
pnenzi 2003-08-23 22:27:36 +00:00
parent 1471aac6b2
commit a6517ea488
2 changed files with 7 additions and 22 deletions

View File

@ -337,35 +337,25 @@ trcopy(struct pnode *tree, char *args, struct pnode *nn)
} else
return (tree);
} else if (tree->pn_func) {
struct func *func;
func = alloc(struct func);
func->fu_name = copy(tree->pn_func->fu_name);
func->fu_func = tree->pn_func->fu_func;
pn = alloc(struct pnode);
pn->pn_value = NULL;
pn->pn_func = func;
/* pn_func are pointers to a global constant struct */
pn->pn_func = tree->pn_func;
pn->pn_op = NULL;
pn->pn_left = trcopy(tree->pn_left, args, nn);
pn->pn_right = NULL;
pn->pn_next = NULL;
} else if (tree->pn_op) {
struct op *op;
op = alloc(struct op);
op->op_num = tree->pn_op->op_num;
op->op_arity = tree->pn_op->op_arity;
op->op_func = tree->pn_op->op_func;
op->op_name = copy(tree->pn_op->op_name);
pn = alloc(struct pnode);
pn->pn_value = NULL;
pn->pn_func = NULL;
pn->pn_op = op;
/* pn_op are pointers to a global constant struct */
pn->pn_op = tree->pn_op;
pn->pn_left = trcopy(tree->pn_left, args, nn);
if (op->op_arity == 2)
if (pn->pn_op->op_arity == 2)
pn->pn_right = trcopy(tree->pn_right, args, nn);
else
pn->pn_right = NULL;

View File

@ -863,14 +863,9 @@ free_pnode(struct pnode *t)
free_pnode(t->pn_left);
free_pnode(t->pn_right);
free_pnode(t->pn_next);
tfree(t->pn_name); /* va: it is a copy() of original string, can be free'd */
/* va: tfree struct func, allocated within parser */
// if (t->pn_func!=NULL) {
// tfree(t->pn_func->fu_name); /* va: name is a copy of original string */
// tfree(t->pn_func); /* va: t->pn_func->fu_func must not tfree'd */
// }
tfree(t->pn_name);
if (t->pn_value)
vec_free(t->pn_value); /* patch by Stefan Jones */
vec_free(t->pn_value);
tfree(t);
}