예제 #1
0
static void free_node_t(struct node_t *p)
{
    if(!p) return; /* just to make sure*/
  
    if(p->op == O_ID || p->op == O_NUM) {
	/* p->left is char *, or int * (malloced)*/
	free(p->left);
	p->left = NULL;
    }
    else {
	if(p->left) free_node_t(p->left);
	if(p->right) free_node_t(p->right);
    }
    free(p);
}
예제 #2
0
/*
 * judge if bw is OK in 'rulestr'
 *          return value:     0 ... no, it's not OK.
 *                        non 0 ... yes, it is. use this rule.
 */
int asmrule_match(char *rulestr,int bw)
{
    int ret = 0;
    struct node_t *p;
    struct c_desc *cd;
  
    if(rulestr[0] != '#') { /* asmrule always start with #*/
	return 1; /* if not, it's no description rule --> always match */
    }
  
    cd = new_c_desc(rulestr + 1);
  
    p = cond_expr(cd);

    /*tree_debug(p); debugging*/
  
    insert_id_value(p,"OldPNMPlayer",0); /* we don't care about old player */
    insert_id_value(p,"Bandwidth",bw);
  
    ret = eval_tree(p);
  
    free_node_t(p);
    free_c_desc(cd);
  
    return ret;
}
void free_names() {
	free_node_t(names);
	names = NULL;
}