コード例 #1
0
char *test_create()
{
    queue = Queue_create();
    mu_assert(queue != NULL, "Failed to create queue.");

    return NULL;
}
コード例 #2
0
ファイル: packets.c プロジェクト: darknrgy/6WD-Robot
Queue* Packets_getQueue(){
	static Queue queue;
	static char is_created = 0x00;
	if (is_created == 0x00){
		// create the queue
		queue = Queue_create(10, sizeof (Packet) );
		is_created = 0x01;
	}
	return &queue;
}
コード例 #3
0
/**
 * usage: this method creates the UART task, interacting with the queue,
 * 		  which is filled in the i2c_method
 * @method setup_UART_Task
 * @author: patrik.szabo
 * @param *none*
 * @return 0, if everything succeeded
 */
int setup_UART_Task(void) {
	Task_Params taskUARTParams;
	Task_Handle taskUART;
	Error_Block eb;

	Error_init(&eb);
	Task_Params_init(&taskUARTParams);
	taskUARTParams.stackSize = 1024; // stack in bytes
	taskUARTParams.priority = 14; // 15 is default 16 is highest priority -> see RTOS configuration
	taskUART = Task_create((Task_FuncPtr) uart_method, &taskUARTParams, &eb);
	if (taskUART == NULL) {
		System_abort("TaskUART create failed");
	}

	uartQueue = Queue_create(NULL, NULL);

	// TODO: this should be in external module
	externalModuleQueue = Queue_create(NULL, NULL);

	return (0);
}
コード例 #4
0
ファイル: treefun.c プロジェクト: AdvancedC/ECE264Assignments
/**
 * Pretty formatting of a binary tree to the output stream
 *
 * Parameters:
 * fp           FILE * to print to. Just use 'stdout' if you are unsure.
 * root         Root of Huffman Coding Tree that we're printing
 * level        Control how wide you want the tree to sparse (eg, level 1 has
 *              the minimum space between nodes, while level 2 has a larger
 *              space between nodes)
 * indent       Change this to add some indent space to the left (eg,
 *              indent of 0 means the lowest level of the left node will
 *              stick to the left margin)
 */
static void HuffNode_printPretty_Worker(FILE * fp, HuffNode * root, int level, 
					int indent) 
{
    int r, i; // for-loop indices
    int h = HuffNode_height(root);

    // eq of the length of branch for each node of each level
    int branch_sz = 2*((1 << h) - 1) - (3-level)*(1 << (h-1));

    // distance between left neighbor node's right arm and right neighbor 
    // node's left arm
    int node_spacing_sz = 2 + (level+1)*(1 << h);

    // starting space to the first node to print of each level 
    // (for the left most node of each level only)
    int start_sz = branch_sz + (3-level) + indent;  
    
    Queue * Q = Queue_create();
    Queue_pushBack(Q, root);
    int curr_tree_width = 1;
    for (r = 1; r < h; r++) {
	print_branches(fp, Q, branch_sz, node_spacing_sz, 
		       start_sz, curr_tree_width);
	branch_sz = branch_sz / 2 - 1;
	node_spacing_sz = node_spacing_sz / 2 + 1;
	start_sz = branch_sz + (3-level) + indent;
	print_nodes(fp, Q, branch_sz, node_spacing_sz, 
		    start_sz, curr_tree_width);
	for (i = 0; i < curr_tree_width; i++) {
	    HuffNode * currNode = Queue_popFront(Q);
	    if(currNode) {
		Queue_pushBack(Q, currNode->left);
		Queue_pushBack(Q, currNode->right);
	    } else {
		Queue_pushBack(Q, NULL);
		Queue_pushBack(Q, NULL);
	    }
	}
	curr_tree_width *= 2;
    }
    print_branches(fp, Q, branch_sz, node_spacing_sz, 
		   start_sz, curr_tree_width);
    print_leaves(fp, Q, indent, level, curr_tree_width);
    Queue_destroy(Q);
}