Avoid using stack.
This commit is contained in:
parent
4e712ec3b7
commit
c454872f4e
1 changed files with 6 additions and 4 deletions
|
@ -27,15 +27,17 @@ static int make_pair(int i1, int i2)
|
||||||
|
|
||||||
struct f_tree *f_generate_rev_wcard(int from, int to, int expr)
|
struct f_tree *f_generate_rev_wcard(int from, int to, int expr)
|
||||||
{
|
{
|
||||||
struct f_tree * ret = NULL;
|
struct f_tree *ret = NULL, *last = NULL;
|
||||||
if(from <= to) {
|
|
||||||
|
while (from <= to) {
|
||||||
ret = f_new_tree();
|
ret = f_new_tree();
|
||||||
ret->from.type = ret->to.type = T_PAIR;
|
ret->from.type = ret->to.type = T_PAIR;
|
||||||
ret->from.val.i = ret->to.val.i = make_pair(from, expr);
|
ret->from.val.i = ret->to.val.i = make_pair(from, expr);
|
||||||
ret->left = f_generate_rev_wcard(from+1, to, expr);
|
ret->left = last;
|
||||||
|
|
||||||
|
from++; last = ret;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CF_DECLS
|
CF_DECLS
|
||||||
|
|
Loading…
Reference in a new issue