]> wimlib.net Git - wimlib/blobdiff - src/lzx-decompress.c
lzx-compress.c: Rename lzx_record_ctx.matches
[wimlib] / src / lzx-decompress.c
index bbb105144710464068c33a9eeaabdb41ea452c05..c98b84c038ed55a09c2e43c4be971422cb6ffcb8 100644 (file)
 #  include "config.h"
 #endif
 
-#include "wimlib.h"
 #include "wimlib/decompressor_ops.h"
 #include "wimlib/decompress_common.h"
+#include "wimlib/error.h"
 #include "wimlib/lzx.h"
 #include "wimlib/util.h"
 
@@ -523,9 +523,6 @@ lzx_decode_match(unsigned main_element, int block_type,
        unsigned num_extra_bits;
        u32 verbatim_bits;
        u32 aligned_bits;
-       unsigned i;
-       u8 *match_dest;
-       u8 *match_src;
 
        /* The main element is offset by 256 because values under 256 indicate a
         * literal value. */
@@ -621,24 +618,8 @@ lzx_decode_match(unsigned main_element, int block_type,
                return -1;
        }
 
-       match_dest = window + window_pos;
-       match_src = match_dest - match_offset;
-
-#if 0
-       printf("Match: src %u, dst %u, len %u\n", match_src - window,
-                                               match_dest - window,
-                                               match_len);
-       putchar('|');
-       for (i = 0; i < match_len; i++) {
-               match_dest[i] = match_src[i];
-               putchar(match_src[i]);
-       }
-       putchar('|');
-       putchar('\n');
-#else
-       for (i = 0; i < match_len; i++)
-               match_dest[i] = match_src[i];
-#endif
+       lz_copy(&window[window_pos], match_len, match_offset,
+               &window[window_pos + bytes_remaining]);
 
        return match_len;
 }
@@ -809,7 +790,7 @@ lzx_free_decompressor(void *_ctx)
 {
        struct lzx_decompressor *ctx = _ctx;
 
-       FREE(ctx);
+       ALIGNED_FREE(ctx);
 }
 
 static int
@@ -822,7 +803,8 @@ lzx_create_decompressor(size_t max_window_size,
        if (!lzx_window_size_valid(max_window_size))
                return WIMLIB_ERR_INVALID_PARAM;
 
-       ctx = MALLOC(sizeof(struct lzx_decompressor));
+       ctx = ALIGNED_MALLOC(sizeof(struct lzx_decompressor),
+                            DECODE_TABLE_ALIGNMENT);
        if (ctx == NULL)
                return WIMLIB_ERR_NOMEM;