X-Git-Url: https://git.sesse.net/?p=fjl;a=blobdiff_plain;f=input.c;h=a36d83fd969f0acf7d543a22fbe2689539bb3d49;hp=603eb6da31bf42e924a0ab83b713d38b7bc36602;hb=516dec3abb3f9e3de96e750d615b123e12d498ff;hpb=47de6c270a336574dce220cde780a802a513d113 diff --git a/input.c b/input.c index 603eb6d..a36d83f 100644 --- a/input.c +++ b/input.c @@ -7,7 +7,7 @@ void init_bit_source(struct bit_source* source, input_func_t* input_func, void* userdata) { memset(source, 0, sizeof(*source)); - source->bytes = (uint8_t*)malloc(bytereservoir_size); + source->bytes = (uint8_t*)malloc(BYTERESERVOIR_SIZE); source->input_func = input_func; source->userdata = userdata; } @@ -15,11 +15,11 @@ void init_bit_source(struct bit_source* source, input_func_t* input_func, void* void possibly_refill_slow_path(struct bit_source* source, unsigned num_bits) { // First, make sure there's stuff in the byte reservoir if we can. - assert(source->bytes_available <= bytereservoir_size); + assert(source->bytes_available <= BYTERESERVOIR_SIZE); // Read data from the source until we have enough to satisfy the request. while (source->bits_available + 8 * source->bytes_available < num_bits) { - const size_t bytes_to_read = bytereservoir_size - source->bytes_available; + const size_t bytes_to_read = BYTERESERVOIR_SIZE - source->bytes_available; const ssize_t bytes_read = (*source->input_func)(source->userdata, source->bytes + source->bytes_available, @@ -45,11 +45,11 @@ void possibly_refill_slow_path(struct bit_source* source, unsigned num_bits) // Fill the bit reservoir one by one byte until we have enough. while (source->bits_available < num_bits) { assert(source->bytes_available > 0); - assert(source->bits_available + 8 <= bitreservoir_size); + assert(source->bits_available + 8 <= BITRESERVOIR_SIZE); uint8_t byte = *(source->bytes); ++source->bytes; --source->bytes_available; - source->bits |= ((bitreservoir_t)byte << (bitreservoir_size - source->bits_available - 8)); + source->bits |= ((bitreservoir_t)byte << (BITRESERVOIR_SIZE - source->bits_available - 8)); source->bits_available += 8; } }