/* Find the lowest probability node in a Huffman table, and mark it as being assigned to a higher probability. Returns the node index of the lowest unused node, or -1 if all nodes are used.  */
static int huff_smallest_node(hnode *hnodes, int num_hnodes)
/* Find the lowest probability node in a Huffman table, and mark it as being assigned to a higher probability. Returns the node index of the lowest unused node, or -1 if all nodes are used.  */
static int huff_smallest_node(hnode *hnodes, int num_hnodes)
{
        if(hnodes[i].used)
            continue;
        if(!hnodes[i].count)
            continue;
        if(hnodes[i].count < best) {
            best = hnodes[i].count;
            best_node = i;
        }
    }
    if(best_node == -1)
        return -1;
    hnodes[best_node].used = 1;
    return best_node;
}