1
0
mirror of https://gitlab.com/bzip2/bzip2.git synced 2026-10-23 09:48:56 +03:00

RandState: use snake_case names for fields

This commit is contained in:
Federico Mena Quintero
2019-06-11 13:16:59 -05:00
committed by Micah Snyder
parent 04f0b0a10b
commit b85dc9b77d
2 changed files with 13 additions and 13 deletions

View File

@@ -128,8 +128,8 @@ extern void bz_internal_error ( int errcode );
/* Keep this in sync with bzlib_rust/src/rand_rable.rs:RandState */
typedef struct {
Int32 rNToGo;
Int32 rTPos;
Int32 n_to_go;
Int32 table_pos;
} RandState;
/* Defined in bzlib_rust/src/rand_rable.rs */

View File

@@ -57,21 +57,21 @@ const RAND_TABLE: [i32; 512] = [
// Keep this in sync with bzlib_private.h:
#[repr(C)]
pub struct RandState {
rNToGo: i32,
rTPos: i32,
n_to_go: i32,
table_pos: i32,
}
#[no_mangle]
pub unsafe extern "C" fn BZ2_rand_init() -> RandState {
RandState {
rNToGo: 0,
rTPos: 0,
n_to_go: 0,
table_pos: 0,
}
}
#[no_mangle]
pub unsafe extern "C" fn BZ2_rand_mask(r: &RandState) -> i32 {
if r.rNToGo == 1 {
if r.n_to_go == 1 {
1
} else {
0
@@ -80,12 +80,12 @@ pub unsafe extern "C" fn BZ2_rand_mask(r: &RandState) -> i32 {
#[no_mangle]
pub unsafe extern "C" fn BZ2_rand_update_mask(r: &mut RandState) {
if r.rNToGo == 0 {
r.rNToGo = RAND_TABLE[r.rTPos as usize];
r.rTPos += 1;
if r.rTPos == 512 {
r.rTPos = 0;
if r.n_to_go == 0 {
r.n_to_go = RAND_TABLE[r.table_pos as usize];
r.table_pos += 1;
if r.table_pos == 512 {
r.table_pos = 0;
}
}
r.rNToGo -= 1;
r.n_to_go -= 1;
}