library/src/utility/BP-StringUtilities.cc
// Since columnizations typically don't work within the greater mindest of tailqueue allocators, this
// routine allows you to duplicate a columnization and store it in a tailqueue.
Since columnizations typically don't work within the greater mindest of tailqueue allocators, this
routine allows you to duplicate a columnization and store it in a tailqueue.
Since columnizations typically don ' t work within the greater mindest of tailqueue allocators this routine allows you to duplicate a columnization and store it in a tailqueue .
P_BP_GENERIC_STRING_COLUMNIZATION BP_StoreColumnizationInTailQ(P_BP_GENERIC_STRING_COLUMNIZATION columnization, P_BP_LINKL tq, BP_BOOL destroy_copied_columnization)
{
	if(!columnization || !tq)
		return NULL;
	P_BP_GENERIC_STRING_COLUMNIZATION ret_val = (P_BP_GENERIC_STRING_COLUMNIZATION) tq_calloc(tq, sizeof(BP_GENERIC_STRING_COLUMNIZATION), 1, BPLN);
	if(columnization->color_normalization_data)
	{
		ret_val->color_normalization_data = (size_t *) tq_calloc(tq, sizeof(size_t) * (columnization->column_count+1), 1, BPLN);
		memcpy(ret_val->color_normalization_data, columnization->color_normalization_data, sizeof(size_t) * columnization->column_count);
	}
	if(columnization->space_normalization_data)
	{
		ret_val->space_normalization_data = (size_t *) tq_calloc(tq, sizeof(size_t) * (columnization->column_count+1), 1, BPLN);
		memcpy(ret_val->space_normalization_data, columnization->space_normalization_data, sizeof(size_t) * columnization->column_count);
	}
	if(columnization->columns)
	{
		ret_val->columns                  = (char **)  tq_calloc(tq, sizeof(char *) * (columnization->column_count+1), 1, BPLN);
		size_t n = 0;
		for(; n < columnization->column_count; n++)
			ret_val->columns[n] = (char *) tq_strdup(tq, columnization->columns[n], BPLN);
	}
	ret_val->column_count             = columnization->column_count;
	ret_val->longest_width            = columnization->longest_width;
	ret_val->longest_width_colorized  = columnization->longest_width_colorized;
	ret_val->tq = tq;
	BP_DestroyGenericColumnization(columnization, BP_TRUE, columnization->tq);
	return ret_val;
}
P_BP_GENERIC_STRING_COLUMNIZATION BP_StoreColumnizationInTailQ ( P_BP_GENERIC_STRING_COLUMNIZATION columnization , P_BP_LINKL tq , BP_BOOL destroy_copied_columnization ) { if ( ! columnization || ! tq ) return NULL ; P_BP_GENERIC_STRING_COLUMNIZATION ret_val = ( P_BP_GENERIC_STRING_COLUMNIZATION ) tq_calloc ( tq , sizeof ( BP_GENERIC_STRING_COLUMNIZATION ) , 1 , BPLN ) ; if ( columnization -> color_normalization_data ) { ret_val -> color_normalization_data = ( size_t * ) tq_calloc ( tq , sizeof ( size_t ) * ( columnization -> column_count + 1 ) , 1 , BPLN ) ; memcpy ( ret_val -> color_normalization_data , columnization -> color_normalization_data , sizeof ( size_t ) * columnization -> column_count ) ; } if ( columnization -> space_normalization_data ) { ret_val -> space_normalization_data = ( size_t * ) tq_calloc ( tq , sizeof ( size_t ) * ( columnization -> column_count + 1 ) , 1 , BPLN ) ; memcpy ( ret_val -> space_normalization_data , columnization -> space_normalization_data , sizeof ( size_t ) * columnization -> column_count ) ; } if ( columnization -> columns ) { ret_val -> columns = ( char * * ) tq_calloc ( tq , sizeof ( char * ) * ( columnization -> column_count + 1 ) , 1 , BPLN ) ; size_t n = 0 ; for ( ; n < columnization -> column_count ; n ++ ) ret_val -> columns [ n ] = ( char * ) tq_strdup ( tq , columnization -> columns [ n ] , BPLN ) ; } ret_val -> column_count = columnization -> column_count ; ret_val -> longest_width = columnization -> longest_width ; ret_val -> longest_width_colorized = columnization -> longest_width_colorized ; ret_val -> tq = tq ; BP_DestroyGenericColumnization ( columnization , BP_TRUE , columnization -> tq ) ; return ret_val ; }
Since columnizations typically don't work within the greater mindest of tailqueue allocators, this
routine allows you to duplicate a columnization and store it in a tailqueue.
Since columnizations typically don ' t work within the greater mindest of tailqueue allocators this routine allows you to duplicate a columnization and store it in a tailqueue .
// ensure we have a columnization and a tail queue allocator // create space to store here // allocate color normalization data // allocate space for normalization data // copy in color normalization data // allocate space normalization data // allocate space for normalization data // copy in normalization data // copy in columns if set // allocate space for columns // copy in column data by duplicating strings // set static members // set tailqueue allocator here // destroy columnization here // copy data into normalization arrays