FreeBSD/sys/dev/bhnd/nvram/nvram_subr.c
/**
 * Return the variable definition for @p varname, if any.
 * 
 * @param varname variable name
 * 
 * @retval bhnd_nvram_var If a valid definition for @p varname is found.
 * @retval NULL If no definition for @p varname is found. 
 */
Return the variable definition for @p varname, if any.

@param varname variable name

@retval bhnd_nvram_var If a valid definition for @p varname is found.
@retval NULL If no definition for @p varname is found.
Return the variable definition for @p varname if any . @param varname variable name @retval bhnd_nvram_var If a valid definition for @p varname is found . @retval NULL If no definition for @p varname is found .
const struct bhnd_nvram_var *
bhnd_nvram_var_defn(const char *varname)
{
	size_t	min, mid, max;
	int	order;
	min = 0;
	mid = 0;
	max = nitems(bhnd_nvram_vars) - 1;
	while (max >= min) {
		mid = (min + max) / 2;
		order = strcmp(bhnd_nvram_vars[mid].name, varname);
		if (order < 0) {
			min = mid + 1;
		} else if (order > 0) {
			max = mid - 1;
		} else if (order == 0) {
			return (&bhnd_nvram_vars[mid]);
		}
	}
	return (NULL);
}
const struct bhnd_nvram_var * bhnd_nvram_var_defn ( const char * varname ) { size_t min , mid , max ; int order ; min = 0 ; mid = 0 ; max = nitems ( bhnd_nvram_vars ) - 1 ; while ( max >= min ) { mid = ( min + max ) / 2 ; order = strcmp ( bhnd_nvram_vars [ mid ] . name , varname ) ; if ( order < 0 ) { min = mid + 1 ; } else if ( order > 0 ) { max = mid - 1 ; } else if ( order == 0 ) { return ( & bhnd_nvram_vars [ mid ] ) ; } } return ( NULL ) ; }
Return the variable definition for @p varname, if any.
Return the variable definition for @p varname if any .
/*
	 * Locate the requested variable using a binary search.
	 * 
	 * The variable table is guaranteed to be sorted in lexicographical
	 * order (using the 'C' locale for collation rules)
	 */ /* Select midpoint */ /* Determine which side of the partition to search */ /* Search upper partition */ /* Search lower partition */ /* Match found */ /* Not found */