library/src/utility/BP-StringUtilities.cc
// Clones a border set on the heap.  If a tq is set, it will be cloned within that allocator.
Clones a border set on the heap.  If a tq is set, it will be cloned within that allocator.
Clones a border set on the heap . If a tq is set it will be cloned within that allocator .
P_BP_STRING_ROW_BORDER_SET BP_CloneBorderSet(P_BP_STRING_ROW_BORDER_SET border_set_to_clone, P_BP_LINKL tq)
{
	if(!border_set_to_clone)
		return NULL;
	P_BP_STRING_ROW_BORDER_SET ret_border_set = NULL;
	if(tq)
	{
		ret_border_set = (P_BP_STRING_ROW_BORDER_SET) tq_calloc(tq, sizeof(BP_STRING_ROW_BORDER_SET), 1, BPLN);
		ret_border_set->tq = tq;
		ret_border_set->allocated_via_tailqueue = BP_TRUE;
		ret_border_set->border_left                = tq_strdup(tq, border_set_to_clone->border_left, BPLN);
		ret_border_set->border_right               = tq_strdup(tq, border_set_to_clone->border_right, BPLN);
		ret_border_set->border_top_char            = tq_strdup(tq, border_set_to_clone->border_top_char, BPLN);
		ret_border_set->border_top_left_corner     = tq_strdup(tq, border_set_to_clone->border_top_left_corner, BPLN);
		ret_border_set->border_top_right_corner    = tq_strdup(tq, border_set_to_clone->border_top_right_corner, BPLN);
		ret_border_set->border_bottom_char         = tq_strdup(tq, border_set_to_clone->border_bottom_char, BPLN);
		ret_border_set->border_bottom_left_corner  = tq_strdup(tq, border_set_to_clone->border_bottom_left_corner, BPLN);
		ret_border_set->border_bottom_right_corner = tq_strdup(tq, border_set_to_clone->border_bottom_right_corner, BPLN);
	}
	else
	{
		ret_border_set = (P_BP_STRING_ROW_BORDER_SET) tq_calloc(tq, sizeof(BP_STRING_ROW_BORDER_SET), 1, BPLN);
		ret_border_set->border_left                = bpstrdup(border_set_to_clone->border_left);
		ret_border_set->border_right               = bpstrdup(border_set_to_clone->border_right);
		ret_border_set->border_top_char            = bpstrdup(border_set_to_clone->border_top_char);
		ret_border_set->border_top_left_corner     = bpstrdup(border_set_to_clone->border_top_left_corner);
		ret_border_set->border_top_right_corner    = bpstrdup(border_set_to_clone->border_top_right_corner);
		ret_border_set->border_bottom_char         = bpstrdup(border_set_to_clone->border_bottom_char);
		ret_border_set->border_bottom_left_corner  = bpstrdup(border_set_to_clone->border_bottom_left_corner);
		ret_border_set->border_bottom_right_corner = bpstrdup(border_set_to_clone->border_bottom_right_corner);
	}
	ret_border_set->border_bottom_right_corner_len_if_colorized = border_set_to_clone->border_bottom_right_corner_len_if_colorized;
	ret_border_set->border_bottom_left_corner_len_if_colorized  = border_set_to_clone->border_bottom_left_corner_len_if_colorized;
	ret_border_set->border_bottom_char_len_if_colorized         = border_set_to_clone->border_bottom_char_len_if_colorized;
	ret_border_set->border_bottom_enabled                       = border_set_to_clone->border_bottom_enabled;
	ret_border_set->border_top_right_corner_len_if_colorized    = border_set_to_clone->border_top_right_corner_len_if_colorized;
	ret_border_set->border_top_left_corner_len_if_colorized     = border_set_to_clone->border_top_left_corner_len_if_colorized;
	ret_border_set->border_top_char_len_if_colorized            = border_set_to_clone->border_top_char_len_if_colorized;
	ret_border_set->border_top_enabled                          = border_set_to_clone->border_top_enabled;
	ret_border_set->border_right_display_len_if_colorized       = border_set_to_clone->border_right_display_len_if_colorized;
	ret_border_set->border_left_display_len_if_colorized        = border_set_to_clone->border_left_display_len_if_colorized;
	return ret_border_set;
}
P_BP_STRING_ROW_BORDER_SET BP_CloneBorderSet ( P_BP_STRING_ROW_BORDER_SET border_set_to_clone , P_BP_LINKL tq ) { if ( ! border_set_to_clone ) return NULL ; P_BP_STRING_ROW_BORDER_SET ret_border_set = NULL ; if ( tq ) { ret_border_set = ( P_BP_STRING_ROW_BORDER_SET ) tq_calloc ( tq , sizeof ( BP_STRING_ROW_BORDER_SET ) , 1 , BPLN ) ; ret_border_set -> tq = tq ; ret_border_set -> allocated_via_tailqueue = BP_TRUE ; ret_border_set -> border_left = tq_strdup ( tq , border_set_to_clone -> border_left , BPLN ) ; ret_border_set -> border_right = tq_strdup ( tq , border_set_to_clone -> border_right , BPLN ) ; ret_border_set -> border_top_char = tq_strdup ( tq , border_set_to_clone -> border_top_char , BPLN ) ; ret_border_set -> border_top_left_corner = tq_strdup ( tq , border_set_to_clone -> border_top_left_corner , BPLN ) ; ret_border_set -> border_top_right_corner = tq_strdup ( tq , border_set_to_clone -> border_top_right_corner , BPLN ) ; ret_border_set -> border_bottom_char = tq_strdup ( tq , border_set_to_clone -> border_bottom_char , BPLN ) ; ret_border_set -> border_bottom_left_corner = tq_strdup ( tq , border_set_to_clone -> border_bottom_left_corner , BPLN ) ; ret_border_set -> border_bottom_right_corner = tq_strdup ( tq , border_set_to_clone -> border_bottom_right_corner , BPLN ) ; } else { ret_border_set = ( P_BP_STRING_ROW_BORDER_SET ) tq_calloc ( tq , sizeof ( BP_STRING_ROW_BORDER_SET ) , 1 , BPLN ) ; ret_border_set -> border_left = bpstrdup ( border_set_to_clone -> border_left ) ; ret_border_set -> border_right = bpstrdup ( border_set_to_clone -> border_right ) ; ret_border_set -> border_top_char = bpstrdup ( border_set_to_clone -> border_top_char ) ; ret_border_set -> border_top_left_corner = bpstrdup ( border_set_to_clone -> border_top_left_corner ) ; ret_border_set -> border_top_right_corner = bpstrdup ( border_set_to_clone -> border_top_right_corner ) ; ret_border_set -> border_bottom_char = bpstrdup ( border_set_to_clone -> border_bottom_char ) ; ret_border_set -> border_bottom_left_corner = bpstrdup ( border_set_to_clone -> border_bottom_left_corner ) ; ret_border_set -> border_bottom_right_corner = bpstrdup ( border_set_to_clone -> border_bottom_right_corner ) ; } ret_border_set -> border_bottom_right_corner_len_if_colorized = border_set_to_clone -> border_bottom_right_corner_len_if_colorized ; ret_border_set -> border_bottom_left_corner_len_if_colorized = border_set_to_clone -> border_bottom_left_corner_len_if_colorized ; ret_border_set -> border_bottom_char_len_if_colorized = border_set_to_clone -> border_bottom_char_len_if_colorized ; ret_border_set -> border_bottom_enabled = border_set_to_clone -> border_bottom_enabled ; ret_border_set -> border_top_right_corner_len_if_colorized = border_set_to_clone -> border_top_right_corner_len_if_colorized ; ret_border_set -> border_top_left_corner_len_if_colorized = border_set_to_clone -> border_top_left_corner_len_if_colorized ; ret_border_set -> border_top_char_len_if_colorized = border_set_to_clone -> border_top_char_len_if_colorized ; ret_border_set -> border_top_enabled = border_set_to_clone -> border_top_enabled ; ret_border_set -> border_right_display_len_if_colorized = border_set_to_clone -> border_right_display_len_if_colorized ; ret_border_set -> border_left_display_len_if_colorized = border_set_to_clone -> border_left_display_len_if_colorized ; return ret_border_set ; }
Clones a border set on the heap.
Clones a border set on the heap .
// ensure we have a border set to work with // allocate via tailqueue if one is provided, if not, allocate normally // create the border set using tail queue allocator // set tailqueue here // set flag here indicating allocation via tail queue // allocate individual elements using tail queue allocator // create the border set using standard allocator // allocate individual elements using standard allocator // set integer/size_t/bool values (literal, doesn't depend on heap allocations) // return with the border set