library/src/utility/BP-StringUtilities.cc
// checks a stack of strings to see if the string is already
// in the stack.
checks a stack of strings to see if the string is already
in the stack.
checks a stack of strings to see if the string is already in the stack .
BP_ERROR_T BP_StringExistsInPointerArray(char ** strings_to_search, size_t stack_size, char *string)
{
	if(!strings_to_search)
		return ERR_FAILURE;
	if(!stack_size)
		return ERR_FAILURE;
	if(!string)
		return ERR_FAILURE;
	size_t n = 0;
	for(; n < stack_size; n++)
	{
		if(!strings_to_search[n])
			return ERR_FAILURE;
		size_t search_len = strnlen(strings_to_search[n], 4096);
		size_t string_len = strnlen(string, 4096);
		if(search_len != string_len)
			return ERR_FAILURE;
		if(memcmp(string, strings_to_search, search_len) == 0)
			return ERR_SUCCESS;
	}
	return ERR_SUCCESS;
}
BP_ERROR_T BP_StringExistsInPointerArray ( char * * strings_to_search , size_t stack_size , char * string ) { if ( ! strings_to_search ) return ERR_FAILURE ; if ( ! stack_size ) return ERR_FAILURE ; if ( ! string ) return ERR_FAILURE ; size_t n = 0 ; for ( ; n < stack_size ; n ++ ) { if ( ! strings_to_search [ n ] ) return ERR_FAILURE ; size_t search_len = strnlen ( strings_to_search [ n ] , 4096 ) ; size_t string_len = strnlen ( string , 4096 ) ; if ( search_len != string_len ) return ERR_FAILURE ; if ( memcmp ( string , strings_to_search , search_len ) == 0 ) return ERR_SUCCESS ; } return ERR_SUCCESS ; }
checks a stack of strings to see if the string is already
in the stack.
checks a stack of strings to see if the string is already in the stack .
// ensure we have strings to search // check string length // check string length // if the strings match, return success // return indicating success