library/src/utility/BP-StringUtilities.cc
// returns an array full of alternating pointers to the color code sets found in codes.
returns an array full of alternating pointers to the color code sets found in codes.
returns an array full of alternating pointers to the color code sets found in codes .
P_BP_COLOR_CODE_SET_T * BP_GenerateAlternatingColorStack(P_BP_COLOR_CODE_SET_T codes, size_t code_count, size_t num_to_generate_as_alterating, P_BP_LINKL tq)
{
	if(!codes || !code_count || !num_to_generate_as_alterating)
	{
		return NULL;
	}
	P_BP_COLOR_CODE_SET_T * ret_codes = NULL;
	if(tq)
		ret_codes = (P_BP_COLOR_CODE_SET_T *) tq_calloc(tq, sizeof(P_BP_COLOR_CODE_SET_T) * (num_to_generate_as_alterating+1), 1, BPLN);
	else
		ret_codes = (P_BP_COLOR_CODE_SET_T *) bpcalloc(sizeof(P_BP_COLOR_CODE_SET_T) * (num_to_generate_as_alterating+1), 1);
	if(!ret_codes)
		return NULL;
	size_t code_iter = 0;
	size_t n = 0;
	for(; n < num_to_generate_as_alterating; n++, code_iter++)
	{
		if(code_iter == code_count)
			code_iter = 0;
		ret_codes[n] = &codes[code_iter];
	}
	return ret_codes;
}
P_BP_COLOR_CODE_SET_T * BP_GenerateAlternatingColorStack ( P_BP_COLOR_CODE_SET_T codes , size_t code_count , size_t num_to_generate_as_alterating , P_BP_LINKL tq ) { if ( ! codes || ! code_count || ! num_to_generate_as_alterating ) { return NULL ; } P_BP_COLOR_CODE_SET_T * ret_codes = NULL ; if ( tq ) ret_codes = ( P_BP_COLOR_CODE_SET_T * ) tq_calloc ( tq , sizeof ( P_BP_COLOR_CODE_SET_T ) * ( num_to_generate_as_alterating + 1 ) , 1 , BPLN ) ; else ret_codes = ( P_BP_COLOR_CODE_SET_T * ) bpcalloc ( sizeof ( P_BP_COLOR_CODE_SET_T ) * ( num_to_generate_as_alterating + 1 ) , 1 ) ; if ( ! ret_codes ) return NULL ; size_t code_iter = 0 ; size_t n = 0 ; for ( ; n < num_to_generate_as_alterating ; n ++ , code_iter ++ ) { if ( code_iter == code_count ) code_iter = 0 ; ret_codes [ n ] = & codes [ code_iter ] ; } return ret_codes ; }
returns an array full of alternating pointers to the color code sets found in codes.
returns an array full of alternating pointers to the color code sets found in codes .
// ensure we have codes and a code count // ensure we allocated the data ok // this is the iterator that moves between items in the code set which // was passed into this routine. // walk the total number // reset the iterator if we hit our top // set the ret codes // return the codes