From b85dc9b77d32b4e8acc770d82cea6b265d18b862 Mon Sep 17 00:00:00 2001 From: Federico Mena Quintero Date: Tue, 11 Jun 2019 13:16:59 -0500 Subject: [PATCH] RandState: use snake_case names for fields --- bzlib_private.h | 4 ++-- bzlib_rust/src/rand_table.rs | 22 +++++++++++----------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/bzlib_private.h b/bzlib_private.h index 5ba8ed8..17b25dc 100644 --- a/bzlib_private.h +++ b/bzlib_private.h @@ -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 */ diff --git a/bzlib_rust/src/rand_table.rs b/bzlib_rust/src/rand_table.rs index 95e3299..0534d6c 100644 --- a/bzlib_rust/src/rand_table.rs +++ b/bzlib_rust/src/rand_table.rs @@ -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; }