diff options
author | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-29 11:44:03 -0500 |
---|---|---|
committer | Christopher Peplin <chris.peplin@rhubarbtech.com> | 2013-12-29 11:44:03 -0500 |
commit | a855335e3ad18a9d0094357eb39622448f8649a9 (patch) | |
tree | 0c00ced6710ee783febd34d8e28d7f3140031a87 /src/bitfield/bitfield.c | |
parent | 6830d35b449141305f137f78f09c2b879bfb9b33 (diff) |
Standardize argument ordering for bitfield functions.
Diffstat (limited to 'src/bitfield/bitfield.c')
-rw-r--r-- | src/bitfield/bitfield.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/src/bitfield/bitfield.c b/src/bitfield/bitfield.c index b0396413..934d5a6a 100644 --- a/src/bitfield/bitfield.c +++ b/src/bitfield/bitfield.c @@ -55,24 +55,21 @@ uint8_t nthByte(const uint64_t source, const uint16_t byteNum) { return (source >> (64 - ((byteNum + 1) * CHAR_BIT))) & 0xFF; } -uint8_t getNibble(const uint8_t nibble_index, const uint8_t data[], - const uint8_t length) { +uint8_t getNibble(const uint8_t source[], const uint8_t source_length, + const uint8_t nibble_index) { uint8_t byte_index = nibble_index / 2; - uint8_t result; - if(byte_index < length) { - result = data[byte_index]; - if(nibble_index % 2 == 0) { - result >>= NIBBLE_SIZE; - } + uint8_t result = getByte(source, source_length, byte_index); + if(nibble_index % 2 == 0) { + result >>= NIBBLE_SIZE; } result &= bitmask(NIBBLE_SIZE); return result; } -uint8_t getByte(const uint8_t byte_index, const uint8_t data[], - const uint8_t length) { - if(byte_index < length) { - return data[byte_index]; +uint8_t getByte(const uint8_t source[], const uint8_t source_length, + const uint8_t byte_index) { + if(byte_index < source_length) { + return source[byte_index]; } return 0; } |