]> wimlib.net Git - wimlib/blobdiff - src/lzms-compress.c
Fix test for length 2 matches
[wimlib] / src / lzms-compress.c
index 3169218288c79c676911ea3376be2a3688c4b3e9..f7ef633ea0355829f463cf9e71d50e244f1bb88c 100644 (file)
@@ -39,6 +39,7 @@
 #include "wimlib/compress_common.h"
 #include "wimlib/endianness.h"
 #include "wimlib/error.h"
+#include "wimlib/lz_hash.h"
 #include "wimlib/lzms.h"
 #include "wimlib/util.h"
 
@@ -599,18 +600,6 @@ lzms_encode_lz_match(struct lzms_compressor *ctx, u32 length, u32 offset)
        lzms_end_encode_item(ctx, length);
 }
 
-static struct lzms_match
-lzms_get_best_match(struct lzms_compressor *ctx)
-{
-       struct lzms_match match;
-
-       /* TODO */
-
-       match.length = 0;
-
-       return match;
-}
-
 static void
 lzms_record_literal(u8 literal, void *_ctx)
 {
@@ -652,6 +641,19 @@ lzms_fast_encode(struct lzms_compressor *ctx)
 }
 
 #if 0
+
+static struct lzms_match
+lzms_get_best_match(struct lzms_compressor *ctx)
+{
+       struct lzms_match match;
+
+       /* TODO */
+
+       match.length = 0;
+
+       return match;
+}
+
 static void
 lzms_slow_encode(struct lzms_compressor *ctx)
 {
@@ -709,6 +711,7 @@ lzms_init_compressor(struct lzms_compressor *ctx, const u8 *udata, u32 ulen,
 
        /* Copy the uncompressed data into the @ctx->window buffer.  */
        memcpy(ctx->window, udata, ulen);
+       memset(&ctx->window[ulen], 0, 8);
        ctx->cur_window_pos = 0;
        ctx->window_size = ulen;
 
@@ -961,7 +964,7 @@ lzms_create_compressor(size_t max_block_size,
        if (ctx == NULL)
                goto oom;
 
-       ctx->window = MALLOC(max_block_size);
+       ctx->window = MALLOC(max_block_size + 8);
        if (ctx->window == NULL)
                goto oom;