/*
* 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/.
*/
/*
#include "wimlib/decompress_common.h"
#include "wimlib/error.h"
#include "wimlib/lzms.h"
+#include "wimlib/unaligned.h"
#include "wimlib/util.h"
#include <limits.h>
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);
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;
}
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;
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;