library/src/blockclass/BP-BlockClass.cc
// Adds a command to the session (deprecated: use ccAddTryExcept() instead where possible)
Adds a command to the session (deprecated: use ccAddTryExcept() instead where possible)
Adds a command to the session ( deprecated : use ccAddTryExcept () instead where possible )
size_t Block::ccAddCommand(char *command_name) {
	if (!this->cc_session)
	{
		this->AddErrorToStack((char*) "Error in Block::ccAddCommand(): Empty session.");
		return ERR_FAILURE;
	}
	if (!command_name)
	{
		this->AddErrorToStack((char*) "Error in Block::ccAddCommand(): Empty command name.");
		return ERR_FAILURE;
	}
	if (!this->cc_session->commands)
	{
		this->cc_session->commands = (P_BP_CC_DECISION_TREE *) tq_calloc(this->tq, sizeof(P_BP_CC_DECISION_TREE) * 2, 1, BPLN);
		this->cc_session->commands[0] = BP_CCCreateNewDecisionTree(this->cc_session, command_name, NULL);
	}
	else
	{
		size_t i;
		for (i = 1; cc_session->commands[i - 1]; i++)
		{}
		i += 2;
		this->cc_session->commands = (P_BP_CC_DECISION_TREE *) tq_realloc(this->tq, this->cc_session->commands, sizeof(P_BP_CC_DECISION_TREE) * i, BPLN);
		this->cc_session->commands[i - 2] = BP_CCCreateNewDecisionTree(this->cc_session, command_name, NULL);
	}
	return ERR_SUCCESS;
}
size_t Block :: ccAddCommand ( char * command_name ) { if ( ! this -> cc_session ) { this -> AddErrorToStack ( ( char * ) " " ) ; return ERR_FAILURE ; } if ( ! command_name ) { this -> AddErrorToStack ( ( char * ) " " ) ; return ERR_FAILURE ; } if ( ! this -> cc_session -> commands ) { this -> cc_session -> commands = ( P_BP_CC_DECISION_TREE * ) tq_calloc ( this -> tq , sizeof ( P_BP_CC_DECISION_TREE ) * 2 , 1 , BPLN ) ; this -> cc_session -> commands [ 0 ] = BP_CCCreateNewDecisionTree ( this -> cc_session , command_name , NULL ) ; } else { size_t i ; for ( i = 1 ; cc_session -> commands [ i - 1 ] ; i ++ ) { } i += 2 ; this -> cc_session -> commands = ( P_BP_CC_DECISION_TREE * ) tq_realloc ( this -> tq , this -> cc_session -> commands , sizeof ( P_BP_CC_DECISION_TREE ) * i , BPLN ) ; this -> cc_session -> commands [ i - 2 ] = BP_CCCreateNewDecisionTree ( this -> cc_session , command_name , NULL ) ; } return ERR_SUCCESS ; }
Adds a command to the session (deprecated: use ccAddTryExcept() instead where possible)
Adds a command to the session ( deprecated : use ccAddTryExcept () instead where possible )
// two elements on first assignment // get number of commands // increment +2 i a final time for new element + null ptr // allocate space // -2 for proper indexing