Skip to content

Commit 919e96c

Browse files
committed
Removed: bz3_decode_block_bound API.
1 parent c3a78a4 commit 919e96c

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/libbz3.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,8 @@ BZIP3_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_s
651651

652652
data_size -= p * 4 + 1;
653653

654-
if (((model & 2) && (lzp_size > bz3_decode_block_bound(state->block_size) || lzp_size < 0)) ||
655-
((model & 4) && (rle_size > bz3_decode_block_bound(state->block_size) || rle_size < 0))) {
654+
if (((model & 2) && (lzp_size > bz3_bound(state->block_size) || lzp_size < 0)) ||
655+
((model & 4) && (rle_size > bz3_bound(state->block_size) || rle_size < 0))) {
656656
state->last_error = BZ3_ERR_MALFORMED_HEADER;
657657
return -1;
658658
}
@@ -698,7 +698,7 @@ BZIP3_API s32 bz3_decode_block(struct bz3_state * state, u8 * buffer, s32 data_s
698698

699699
// Undo LZP
700700
if (model & 2) {
701-
size_src = lzp_decompress(b1, b2, lzp_size, bz3_decode_block_bound(state->block_size), state->lzp_lut);
701+
size_src = lzp_decompress(b1, b2, lzp_size, bz3_bound(state->block_size), state->lzp_lut);
702702
if (size_src == -1) {
703703
state->last_error = BZ3_ERR_CRC;
704704
return -1;
@@ -868,7 +868,7 @@ BZIP3_API int bz3_decompress(const uint8_t * in, uint8_t * out, size_t in_size,
868868
struct bz3_state * state = bz3_new(block_size);
869869
if (!state) return BZ3_ERR_INIT;
870870

871-
u8 * compression_buf = malloc(bz3_decode_block_bound(block_size));
871+
u8 * compression_buf = malloc(bz3_bound(block_size));
872872
if (!compression_buf) {
873873
bz3_free(state);
874874
return BZ3_ERR_INIT;
@@ -940,13 +940,3 @@ BZIP3_API size_t bz3_memory_needed(int32_t block_size) {
940940
total_size += (1 << LZP_DICTIONARY) * sizeof(int32_t);
941941
return total_size;
942942
}
943-
944-
BZIP3_API size_t bz3_decode_block_bound(size_t orig_size) {
945-
// Block may temporarily exceed the `orig_size` due to
946-
// - RLE not being effective (encoded data pre commit 187b3228c73d4f35916ecb5950f18861ddc853ac)
947-
// - LZP not being effective (encoded data pre commit 187b3228c73d4f35916ecb5950f18861ddc853ac)
948-
// - Burrows Wheeler Transform (added bytes if RLE/LZP didn't save enough space)
949-
// - Arithmetic Coding (on added bytes if prior steps failed)
950-
// The 256-byte padding is claimed by the author as sufficient
951-
return orig_size + 256;
952-
}

0 commit comments

Comments
 (0)