:: commit 862f08a59b438e18692d0bda3d7e8b3789b36bb7

Kamila Szewczyk <kspalaiologos@gmail.com> — 2022-05-02 10:04

parents: 91222aa2b7

integer type abbreviation shorthands

diff --git a/include/common.h b/include/common.h
new file mode 100644
index 0000000..08ba53a
--- /dev/null
+++ b/include/common.h
@@ -0,0 +1,19 @@
+
+#ifndef _COMMON_H
+#define _COMMON_H
+
+#define KiB(x) ((x)*1024)
+#define MiB(x) ((x)*1024 * 1024)
+
+#include <inttypes.h>
+#include <stdint.h>
+
+typedef uint8_t u8;
+typedef uint16_t u16;
+typedef uint32_t u32;
+
+typedef int8_t s8;
+typedef int16_t s16;
+typedef int32_t s32;
+
+#endif
diff --git a/src/main.c b/src/main.c
index d2f8011..24adafc 100644
--- a/src/main.c
+++ b/src/main.c
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <unistd.h>
 
+#include "common.h"
 #include "cm.h"
 #include "crc32.h"
 #include "libsais.h"
@@ -30,9 +31,6 @@
 #include "rle.h"
 #include "srt.h"
 
-#define KiB(x) ((x)*1024)
-#define MiB(x) ((x)*1024 * 1024)
-
 void encode_block(int output_des, int32_t bytes_read, uint8_t * buffer,
                   uint8_t * output, int32_t * sais_array,
                   struct srt_state * srt_state, state * cm_state,
diff --git a/src/rle.c b/src/rle.c
index 45ad4e3..3b2c5da 100644
--- a/src/rle.c
+++ b/src/rle.c
@@ -10,8 +10,8 @@ int32_t mrlec(uint8_t * in, int32_t inlen, uint8_t * out) {
     uint8_t *ip = in, *in_ = in + inlen, *op = out;
     int32_t i;
     int32_t c, pc = -1;
-    int64_t t[256] = { 0 };
-    int64_t run = 0;
+    int32_t t[256] = { 0 };
+    int32_t run = 0;
     while ((c = buffer_read(ip, in_)) != -1) {
         if (c == pc)
             t[c] += (++run % 255) != 0;
@@ -50,8 +50,8 @@ int32_t mrled(uint8_t * in, uint8_t * out, int32_t outlen) {
     int32_t i;
 
     int32_t c, pc = -1;
-    int64_t t[256] = { 0 };
-    int64_t run = 0;
+    int32_t t[256] = { 0 };
+    int32_t run = 0;
 
     for (i = 0; i < 32; ++i) {
         int32_t j;
tab: 248 wrap: offon