X-Git-Url: https://wimlib.net/git/?a=blobdiff_plain;f=src%2Flzms-decompress.c;h=96c501aa9340813c2d72352b8f9096ca9546836e;hb=0ecb0529b5fcacc1abafa1f3f02a40c44783ada8;hp=e2037d4488e93858cdb8316568a3c4f246b3d682;hpb=93110bb18090d4d2c00294a56f819c7edeef318f;p=wimlib diff --git a/src/lzms-decompress.c b/src/lzms-decompress.c index e2037d44..96c501aa 100644 --- a/src/lzms-decompress.c +++ b/src/lzms-decompress.c @@ -5,20 +5,18 @@ /* * Copyright (C) 2013, 2014 Eric Biggers * - * This file is part of wimlib, a library for working with WIM files. + * This file is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 3 of the License, or (at your option) any + * later version. * - * wimlib is free software; you can redistribute it and/or modify it under the - * terms of the GNU General Public License as published by the Free - * Software Foundation; either version 3 of the License, or (at your option) - * any later version. - * - * wimlib is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR - * A PARTICULAR PURPOSE. See the GNU General Public License for more + * This file is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * - * You should have received a copy of the GNU General Public License - * along with wimlib; if not, see http://www.gnu.org/licenses/. + * You should have received a copy of the GNU Lesser General Public License + * along with this file; if not, see http://www.gnu.org/licenses/. */ /* @@ -211,6 +209,7 @@ #include "wimlib/decompress_common.h" #include "wimlib/error.h" #include "wimlib/lzms.h" +#include "wimlib/unaligned.h" #include "wimlib/util.h" #include @@ -395,7 +394,7 @@ lzms_input_bitstream_ensure_bits(struct lzms_input_bitstream *is, if (unlikely(is->num_le16_remaining == 0)) return -1; - next = le16_to_cpu(*--is->in); + next = get_unaligned_u16_le(--is->in); is->num_le16_remaining--; is->bitbuf |= next << (sizeof(is->bitbuf) * 8 - is->num_filled_bits - 16); @@ -452,8 +451,8 @@ lzms_range_decoder_raw_init(struct lzms_range_decoder_raw *rd, const le16 *in, size_t in_limit) { rd->range = 0xffffffff; - rd->code = ((u32)le16_to_cpu(in[0]) << 16) | - ((u32)le16_to_cpu(in[1]) << 0); + rd->code = ((u32)get_unaligned_u16_le(&in[0]) << 16) | + ((u32)get_unaligned_u16_le(&in[1]) << 0); rd->in = in + 2; rd->num_le16_remaining = in_limit - 2; } @@ -467,7 +466,7 @@ lzms_range_decoder_raw_normalize(struct lzms_range_decoder_raw *rd) rd->range <<= 16; if (unlikely(rd->num_le16_remaining == 0)) return -1; - rd->code = (rd->code << 16) | le16_to_cpu(*rd->in++); + rd->code = (rd->code << 16) | get_unaligned_u16_le(rd->in++); rd->num_le16_remaining--; } return 0; @@ -669,7 +668,7 @@ lzms_copy_lz_match(struct lzms_decompressor *ctx, u32 length, u32 offset) out_next = ctx->out_next; - lz_copy(out_next, length, offset, ctx->out_end); + lz_copy(out_next, length, offset, ctx->out_end, 1); ctx->out_next = out_next + length; return 0;