pub fn bufcopy(
    a: &[u8],
    n: usize,
    buffer: &mut [u8],
    b: &mut usize,
    bmax: usize,
    qtb: &mut Buffer3,
) -> i32 {
    for i in 0..n {
        //for (i = 0; i < n; i++) {
        if a[i] != 0 {
            /*
             * add Huffman code for a[i] to buffer
             */
            qtb.bitbuffer |= CODE[a[i] as usize] << qtb.bits_to_go;
            qtb.bits_to_go += NCODE[a[i] as usize];
            if qtb.bits_to_go >= 8 {
                buffer[*b] = qtb.bitbuffer as u8;
                *b += 1;

                /*
                 * return warning code if we fill buffer
                 */
                if *b >= bmax {
                    return 1;
                }

                qtb.bitbuffer >>= 8;
                qtb.bits_to_go -= 8;
            }
        }
    }
    0
}
/*
 * copy non-zero codes from array to buffer
 */
copy non-zero codes from array to buffer
copy non - zero codes from array to buffer
pub fn bufcopy(
    a: &[u8],
    n: usize,
    buffer: &mut [u8],
    b: &mut usize,
    bmax: usize,
    qtb: &mut Buffer3,
) -> i32 {
    for i in 0..n {
        //for (i = 0; i < n; i++) {
        if a[i] != 0 {
            /*
             * add Huffman code for a[i] to buffer
             */
            qtb.bitbuffer |= CODE[a[i] as usize] << qtb.bits_to_go;
            qtb.bits_to_go += NCODE[a[i] as usize];
            if qtb.bits_to_go >= 8 {
                buffer[*b] = qtb.bitbuffer as u8;
                *b += 1;
                /*
                 * return warning code if we fill buffer
                 */
                if *b >= bmax {
                    return 1;
                }
                qtb.bitbuffer >>= 8;
                qtb.bits_to_go -= 8;
            }
        }
    }
    0
}
pub fn bufcopy ( a : & [ u8 ] , n : usize , buffer : & mut [ u8 ] , b : & mut usize , bmax : usize , qtb : & mut Buffer3 , ) -> i32 { for i in 0 .. n { //for (i = 0; i < n; i++) { if a [ i ] != 0 { /*
             * add Huffman code for a[i] to buffer
             */ qtb . bitbuffer |= CODE [ a [ i ] as usize ] << qtb . bits_to_go ; qtb . bits_to_go += NCODE [ a [ i ] as usize ] ; if qtb . bits_to_go >= 8 { buffer [ * b ] = qtb . bitbuffer as u8 ; * b += 1 ; /*
                 * return warning code if we fill buffer
                 */ if * b >= bmax { return 1 ; } qtb . bitbuffer >>= 8 ; qtb . bits_to_go -= 8 ; } } } 0 }
copy non-zero codes from array to buffer
copy non - zero codes from array to buffer
a
&[u8]
n
usize
buffer
&mut [u8]
b
&mut usize
bmax
usize
qtb
&mut Buffer3
a
&[u8]
n
usize
buffer
&mut [u8]
b
&mut usize
bmax
usize
qtb
&mut Buffer3