bugfixes
diff --git a/include/libbz3.h b/include/libbz3.h
index 10cdde3..3431268 100644
--- a/include/libbz3.h
+++ b/include/libbz3.h
@@ -2,13 +2,7 @@
#ifndef _LIBBZ3_H
#define _LIBBZ3_H
-#include "cm.h"
#include "common.h"
-#include "crc32.h"
-#include "libsais.h"
-#include "mtf.h"
-#include "rle.h"
-#include "srt.h"
#define BZ3_OK 0
#define BZ3_ERR_OUT_OF_BOUNDS -1
diff --git a/src/libbz3.c b/src/libbz3.c
index 4eb772c..46c6193 100644
--- a/src/libbz3.c
+++ b/src/libbz3.c
@@ -67,8 +67,8 @@ struct block_encoder_state * new_block_encoder_state(s32 block_size) {
}
block_encoder_state->cm_state = malloc(sizeof(state));
- block_encoder_state->srt_state = malloc(sizeof(struct mtf_state));
- block_encoder_state->mtf_state = malloc(sizeof(struct srt_state));
+ block_encoder_state->srt_state = malloc(sizeof(struct srt_state));
+ block_encoder_state->mtf_state = malloc(sizeof(struct mtf_state));
block_encoder_state->buf1 = malloc(block_size + block_size / 3);
block_encoder_state->buf2 = malloc(block_size + block_size / 3);
diff --git a/src/main.c b/src/main.c
index 96767f6..e4094db 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,14 +23,8 @@
#include <string.h>
#include <unistd.h>
-#include "cm.h"
#include "common.h"
-#include "crc32.h"
#include "libbz3.h"
-#include "libsais.h"
-#include "mtf.h"
-#include "rle.h"
-#include "srt.h"
int main(int argc, char * argv[]) {
// -1: encode, 0: unspecified, 1: encode, 2: test
@@ -99,15 +93,6 @@ int main(int argc, char * argv[]) {
return 1;
}
- struct block_encoder_state * block_encoder_state =
- new_block_encoder_state(block_size);
-
- if (get_last_error(block_encoder_state) != BZ3_OK) {
- fprintf(stderr, "Failed to create block encoder state: %s\n",
- str_last_error(block_encoder_state));
- return 1;
- }
-
switch (mode) {
case 1:
write(output_des, "BZ3v1", 5);
@@ -136,6 +121,14 @@ int main(int argc, char * argv[]) {
}
}
+ struct block_encoder_state * block_encoder_state =
+ new_block_encoder_state(block_size);
+
+ if (block_encoder_state == NULL) {
+ fprintf(stderr, "Failed to create a block encoder state.\n");
+ return 1;
+ }
+
if (mode == 1)
while (commit_read(block_encoder_state,
read(input_des, get_buffer(block_encoder_state),
