library/src/utility/BP-StringUtilities.cc
// Destroys a generic columnization.  Set the second parameter to BP_TRUE if you want to also
// destroy the data which was passed in (aka the structure itself).  You'd not want to enable
// this if you were using a local stack structure (not heap).
Destroys a generic columnization.  Set the second parameter to BP_TRUE if you want to also
destroy the data which was passed in (aka the structure itself).  You'd not want to enable
this if you were using a local stack structure (not heap).
Destroys a generic columnization . Set the second parameter to BP_TRUE if you want to also destroy the data which was passed in ( aka the structure itself ) . You ' d not want to enable this if you were using a local stack structure ( not heap ) .
BP_ERROR_T BP_DestroyGenericColumnization(P_BP_GENERIC_STRING_COLUMNIZATION columnization, BP_BOOL destroy_struct, P_BP_LINKL tq)
{
	if(!columnization)
		return ERR_FAILURE;
	if(!tq)
	{
		if(columnization->color_normalization_data)
		{
			bpfree(columnization->color_normalization_data);
		}
		if(columnization->space_normalization_data)
		{
			bpfree(columnization->space_normalization_data);
		}
		size_t n = 0;
		if(columnization->columns)
		{
			for(; n < columnization->column_count; n++)
				bpfree(columnization->columns[n]);
			bpfree(columnization->columns);
			columnization->columns = NULL;
		}
		if(destroy_struct == BP_TRUE)
		{
			bpfree(columnization);
		}
		else
		{
			memset(columnization, 0x00, sizeof(BP_GENERIC_STRING_COLUMNIZATION));
		}
	}
	else
	{
		if(columnization->color_normalization_data)
		{
			tq_free(tq, columnization->color_normalization_data);
		}
		if(columnization->space_normalization_data)
		{
			tq_free(tq, columnization->space_normalization_data);
		}
		size_t n = 0;
		if(columnization->columns)
		{
			for(; n < columnization->column_count; n++)
				tq_free(tq, columnization->columns[n]);
			tq_free(tq, columnization->columns);
			columnization->columns = NULL;
		}
		if(destroy_struct == BP_TRUE)
		{
			tq_free(tq, columnization);
		}
		else
		{
			memset(columnization, 0x00, sizeof(BP_GENERIC_STRING_COLUMNIZATION));
		}
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_DestroyGenericColumnization ( P_BP_GENERIC_STRING_COLUMNIZATION columnization , BP_BOOL destroy_struct , P_BP_LINKL tq ) { if ( ! columnization ) return ERR_FAILURE ; if ( ! tq ) { if ( columnization -> color_normalization_data ) { bpfree ( columnization -> color_normalization_data ) ; } if ( columnization -> space_normalization_data ) { bpfree ( columnization -> space_normalization_data ) ; } size_t n = 0 ; if ( columnization -> columns ) { for ( ; n < columnization -> column_count ; n ++ ) bpfree ( columnization -> columns [ n ] ) ; bpfree ( columnization -> columns ) ; columnization -> columns = NULL ; } if ( destroy_struct == BP_TRUE ) { bpfree ( columnization ) ; } else { memset ( columnization , 0x00 , sizeof ( BP_GENERIC_STRING_COLUMNIZATION ) ) ; } } else { if ( columnization -> color_normalization_data ) { tq_free ( tq , columnization -> color_normalization_data ) ; } if ( columnization -> space_normalization_data ) { tq_free ( tq , columnization -> space_normalization_data ) ; } size_t n = 0 ; if ( columnization -> columns ) { for ( ; n < columnization -> column_count ; n ++ ) tq_free ( tq , columnization -> columns [ n ] ) ; tq_free ( tq , columnization -> columns ) ; columnization -> columns = NULL ; } if ( destroy_struct == BP_TRUE ) { tq_free ( tq , columnization ) ; } else { memset ( columnization , 0x00 , sizeof ( BP_GENERIC_STRING_COLUMNIZATION ) ) ; } } return ERR_SUCCESS ; }
Destroys a generic columnization.
Destroys a generic columnization .
// ensure we have a pointer // destroy color normalization data // destroy space normalization data // destroy column data // if we're destroying it, go ahead and do it, if not // just zero it out. // destroy color normalization data // destroy space normalization data // destroy column data // if we're destroying it, go ahead and do it, if not // just zero it out. // return indicating success