return new;
}
+/* desallocate element */
+
+void delelement (element_t *root)
+{
+ int i;
+ if ((root != NULL) && (root != ERROR_OP)) {
+ for (i = 0; i < root->nbops; i++) {
+ if ((root->ops[i] != NULL) && (root->ops[i] != ERROR_OP)) {
+ delelement (root->ops[i]);
+ }
+ }
+ free (root);
+ }
+}
+
/* functions */
#define NB_OPERATORS 6
new->ops[0] = *proot;
new->ops[1] = parser (*pstr, pstr, new->prio);
if (new->ops[1] == ERROR_OP) {
+ delelement (new);
+ *proot = NULL;
return ERROR_OP;
}
*proot = newelement (Val, 1, 5);
- if (*proot == ERROR_OP) {
+ if (*proot == NULL) {
+ delelement (new);
return ERROR_OP;
}
(*proot)->ops[0] = new;
found = 0;
new = parser (str + 1, &str, 0);
if (new == ERROR_OP) {
+ delelement (root);
return ERROR_OP;
}
for (i = 0; i < root->nbops; i++) {
}
}
if (!found) {
+ delelement (new);
+ delelement (root);
return ERROR_OP;
}
} while (*str == ',');
}
new = parser (str + 1, &str, 0);
if ((new == ERROR_OP) || (*str == ',')) {
+ delelement (new);
+ delelement (root);
return ERROR_OP;
}
root->ops[0] = new;
str += operator->offset;
VERBOSE (INFO, PRINTOUT ("Oper: %d\n", operator->func));
if (subparser (&root, &str, operator->func, operator->nbops, operator->prio) == ERROR_OP) {
+ delelement (root);
return ERROR_OP;
}
} else if (*str == '-') {
return ERROR_OP;
}
root = new;
- } else {
+ } else {
+ delelement (root);
return ERROR_OP;
}
str += function->offset;
return root;
}
if (subparser (&root, &str, Add, 2, 1) == ERROR_OP) {
+ delelement (root);
return ERROR_OP;
}
} else {
+ delelement (root);
return ERROR_OP;
}
} else {
+ delelement (root);
return ERROR_OP;
}
found = 1;
/* error */
if (!found) {
+ delelement (root);
return ERROR_OP;
}
if (next != NULL) {
*next = str;
}
+
return root;
}