示例#1
0
文件: cspbranc.c 项目: ppdewolf/CSP
static void write_prob()
{
    int      k,cont;
    VARIABLE *col;
    FILE     *pfile;
//    float    t1;
    
//    t1 = seconds();

    pfile = fopen(fbranch,"a");
    if(pfile==NULL){          
          std::cout << "ERROR: not possible to write on " << fbranch << std::endl;
          CSPexit(EXIT_ERROR); //exit(1);
    }
    fseek(pfile,0L,SEEK_END);
    insert_branch( ftell(pfile) );

    for(cont=k=0;k<ncols;k++)
         if( columns[k].stat != FIX_LB ) cont++;
    fprintf(pfile," %d",cont);
    col = columns;
    for(k=0;k<ncols;k++){
         if( col->stat != FIX_LB )
             fprintf(pfile," %p %d",col,col->stat);
         col++;
    }
    for( cont=0 , k=1 ; k<mar ; k++ )
         if( rind[k]->stat ==0 ) cont++;
    fprintf(pfile," %d",cont);
    for(k=1;k<mar;k++)
         if( rind[k]->stat ==0 )
             fprintf(pfile," %p",rind[k]);
    fclose(pfile);
}
/** routetbl_add_branch:
 * 	adds route branch to specified qnet connection
 */
void routetbl_add_branch(
	qnet * net,
	const net_id * nid )
{
	struct rtbl_entry * re = find_entry(net);
	assert(re);

	debug_a("routetbl_add_branch: route to ");
	debug_a(net_id_dump(nid));
	debug_a(" [through ");
	debug_a(net_id_dump(&net->id));
	debug("]");

	/** check that it is'nt already on the list */
	if(find_branch(nid, NULL)) {
		log_a("routetbl_add_branch: the net \"");
		log_a(net_id_dump(nid));
		log("\" already in route table: ignored");
		return;
	}

	/** ok, not found: insert it */
	insert_branch(re, nid);

	/* broadcast new net */
	broadcast_route_change(nid, 1);
}	
示例#3
0
文件: mtree.c 项目: wtaysom/tau
static int insert_node (tree_s *tree, void *node, u64 key, void *rec, unint size)
{
FN;
	switch (magic(node)) {
	case LEAF:	return insert_leaf(tree, node, key, rec, size);
	case BRANCH:	return insert_branch(tree, node, key, rec, size);
	default:	return qERR_BAD_BLOCK;
	}
}
示例#4
0
文件: btree.c 项目: taysom/tau
static int insert_head (
	tree_s	*tree,
	void	*child,
	u64	key,
	void	*rec,
	unint	len)
{
FN;
	switch (type(child)) {
	case LEAF:	return insert_leaf(tree, child, key, rec, len);
	case BRANCH:	return insert_branch(tree, child, key, rec, len);
	default:	return qERR_BAD_BLOCK;
	}
}