iOS/buildlibs/armv7/allegro-4.4.2/addons/jpgalleg/src/encode.c
/* find_leaf_at_level:
 *  Finds first huffman tree node holding a leaf at specified level.
 */
Finds first huffman tree node holding a leaf at specified level.
Finds first huffman tree node holding a leaf at specified level .
static HUFFMAN_NODE *
find_leaf_at_level(HUFFMAN_NODE *node, int level, int cur_level)
{
	HUFFMAN_NODE *result;
	if (node->entry) {
		if (cur_level == level)
			return node;
		return NULL;
	}
	result = find_leaf_at_level(node->left, level, cur_level + 1);
	if (result)
		return result;
	result = find_leaf_at_level(node->right, level, cur_level + 1);
	if (result)
		return result;
	return NULL;
}
static HUFFMAN_NODE * find_leaf_at_level ( HUFFMAN_NODE * node , int level , int cur_level ) { HUFFMAN_NODE * result ; if ( node -> entry ) { if ( cur_level == level ) return node ; return NULL ; } result = find_leaf_at_level ( node -> left , level , cur_level + 1 ) ; if ( result ) return result ; result = find_leaf_at_level ( node -> right , level , cur_level + 1 ) ; if ( result ) return result ; return NULL ; }
find_leaf_at_level:
  Finds first huffman tree node holding a leaf at specified level.
find_leaf_at_level : Finds first huffman tree node holding a leaf at specified level .