library/src/utility/BP-StringFormattingSessions.cc
// Utility routine for adding entries to a search results structure.  Entries
// are tied to the tail queue allocator within the session parameter.
Utility routine for adding entries to a search results structure.  Entries
are tied to the tail queue allocator within the session parameter.
Utility routine for adding entries to a search results structure . Entries are tied to the tail queue allocator within the session parameter .
BP_ERROR_T BP_AddStringResultEntryToSFSSearchResults
(
		P_BP_SFS_SEARCH_RESULTS            sfs_search_results,
		P_BP_SF_SESSION                    session,
		P_BP_SFS_STRING_ROW_GROUP          row_group,
		P_BP_SFS_STRING_ROW                row,
		P_BP_SFS_STRING_COLUMN_GROUP       column_group,
		P_BP_SFS_STRING_COLUMN             column,
		P_BP_SFS_STRING_ENTRY              string_entry
)
{
	if(!sfs_search_results || !session)
		return ERR_FAILURE;
	if(!session->tq)
		return ERR_FAILURE;
	sfs_search_results->results = (P_BP_SFS_SEARCH_RESULT) tq_realloc
	(
		session->tq,
		sfs_search_results->results,
		sizeof(BP_SFS_SEARCH_RESULT) * (sfs_search_results->result_n + 1),
		BPLN
	);
	if(!sfs_search_results->results)
		return ERR_FAILURE;
	size_t idx = sfs_search_results->result_n;
	P_BP_SFS_SEARCH_RESULT iter = &sfs_search_results->results[idx];
	iter->session       = session;
	iter->row_group     = row_group;
	iter->row           = row;
	iter->column_group  = column_group;
	iter->column        = column;
	iter->string_entry  = string_entry;
	sfs_search_results->result_n++;
	return ERR_SUCCESS;
}
BP_ERROR_T BP_AddStringResultEntryToSFSSearchResults ( P_BP_SFS_SEARCH_RESULTS sfs_search_results , P_BP_SF_SESSION session , P_BP_SFS_STRING_ROW_GROUP row_group , P_BP_SFS_STRING_ROW row , P_BP_SFS_STRING_COLUMN_GROUP column_group , P_BP_SFS_STRING_COLUMN column , P_BP_SFS_STRING_ENTRY string_entry ) { if ( ! sfs_search_results || ! session ) return ERR_FAILURE ; if ( ! session -> tq ) return ERR_FAILURE ; sfs_search_results -> results = ( P_BP_SFS_SEARCH_RESULT ) tq_realloc ( session -> tq , sfs_search_results -> results , sizeof ( BP_SFS_SEARCH_RESULT ) * ( sfs_search_results -> result_n + 1 ) , BPLN ) ; if ( ! sfs_search_results -> results ) return ERR_FAILURE ; size_t idx = sfs_search_results -> result_n ; P_BP_SFS_SEARCH_RESULT iter = & sfs_search_results -> results [ idx ] ; iter -> session = session ; iter -> row_group = row_group ; iter -> row = row ; iter -> column_group = column_group ; iter -> column = column ; iter -> string_entry = string_entry ; sfs_search_results -> result_n ++ ; return ERR_SUCCESS ; }
Utility routine for adding entries to a search results structure.
Utility routine for adding entries to a search results structure .
// ensure we have search results and a session to // attribute them to. // ensure we have a tailqueue allocator to work with // allocate new space for results // ensure the results were reallocated ok // create index for readability // create an iter for readability // set items directly (no checks required as NULL values are OK) // since all allocations and assignments were ok, increment the result // counter. // return indicating success