diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-27 17:26:45 +0400 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-10-27 17:26:45 +0400 |
commit | 9ce642f9746dfc29d119d0680b769677e3ea6da6 (patch) | |
tree | f8d2bcd08c691979058b610b32573a742a3e3024 /archival/lzop.c | |
parent | dd88ba88f5082b1785539b1fb87af7320515b8c9 (diff) |
libbb: introduce and use common crc32 routine
function old new delta
crc32_block_endian1 - 37 +37
crc32_block_endian0 - 34 +34
global_crc32_table - 8 +8
file_read 82 87 +5
gzip_main 211 214 +3
xz_crc32 40 35 -5
crc32_table 8 - -8
calculate_gunzip_crc 54 34 -20
lzo_crc32 54 25 -29
cksum_main 298 211 -87
------------------------------------------------------------------------------
(add/remove: 3/1 grow/shrink: 2/4 up/down: 87/-149) Total: -62 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'archival/lzop.c')
-rw-r--r-- | archival/lzop.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/archival/lzop.c b/archival/lzop.c index c6e718ad7..acb34fe14 100644 --- a/archival/lzop.c +++ b/archival/lzop.c @@ -393,7 +393,7 @@ typedef struct header_t { } header_t; struct globals { - const uint32_t *lzo_crc32_table; + /*const uint32_t *lzo_crc32_table;*/ chksum_t chksum_in; chksum_t chksum_out; } FIX_ALIASING; @@ -468,19 +468,10 @@ lzo_adler32(uint32_t adler, const uint8_t* buf, unsigned len) static FAST_FUNC uint32_t lzo_crc32(uint32_t c, const uint8_t* buf, unsigned len) { - uint32_t crc; + //if (buf == NULL) - impossible + // return 0; - if (buf == NULL) - return 0; - - crc = ~c; - if (len != 0) do { - crc = G.lzo_crc32_table[(uint8_t)((int)crc ^ *buf)] ^ (crc >> 8); - buf += 1; - len -= 1; - } while (len > 0); - - return ~crc; + return ~crc32_block_endian0(~c, buf, len, global_crc32_table); } /**********************************************************************/ @@ -679,8 +670,7 @@ static NOINLINE smallint lzo_compress(const header_t *h) if (dst_len < src_len) { /* write checksum of compressed block */ if (h->flags & F_ADLER32_C) - write32(lzo_adler32(ADLER32_INIT_VALUE, b2, - dst_len)); + write32(lzo_adler32(ADLER32_INIT_VALUE, b2, dst_len)); if (h->flags & F_CRC32_C) write32(lzo_crc32(CRC32_INIT_VALUE, b2, dst_len)); /* write compressed block data */ @@ -1080,6 +1070,6 @@ int lzop_main(int argc UNUSED_PARAM, char **argv) if (applet_name[0] == 'u') option_mask32 |= OPT_DECOMPRESS; - G.lzo_crc32_table = crc32_filltable(NULL, 0); + global_crc32_table = crc32_filltable(NULL, 0); return bbunpack(argv, pack_lzop, make_new_name_lzop, /*unused:*/ NULL); } |