From 8018cdba2dcf58923a77b71933970ccc21c18d05 Mon Sep 17 00:00:00 2001 From: jsc Date: Tue, 17 Dec 2019 12:34:13 +0100 Subject: [PATCH 1/3] Fixes compatibility with embedded, non unix devices. --- include/correct.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/correct.h b/include/correct.h index 12d817d..ee0dfba 100644 --- a/include/correct.h +++ b/include/correct.h @@ -3,8 +3,12 @@ #include #ifndef _MSC_VER +#if defined(unix) || defined(__unix__) || defined(__unix) #include #else +#define ssize_t int +#endif +#else #include typedef ptrdiff_t ssize_t; #endif From aa5b7fd8fac39a7f5c1cc609d400948db8fd4cc7 Mon Sep 17 00:00:00 2001 From: jsc Date: Tue, 17 Dec 2019 12:36:54 +0100 Subject: [PATCH 2/3] Suppresses warning: [-Wmaybe-uninitialized] --- src/convolutional/history_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convolutional/history_buffer.c b/src/convolutional/history_buffer.c index f54ffdd..52543b0 100644 --- a/src/convolutional/history_buffer.c +++ b/src/convolutional/history_buffer.c @@ -45,7 +45,7 @@ uint8_t *history_buffer_get_slice(history_buffer *buf) { return buf->history[buf shift_register_t history_buffer_search(history_buffer *buf, const distance_t *distances, unsigned int search_every) { - shift_register_t bestpath; + shift_register_t bestpath = 0; distance_t leasterror = USHRT_MAX; // search for a state with the least error for (shift_register_t state = 0; state < buf->num_states; state += search_every) { From 0584ac7db1f35755126a4fd5a68f1a704e60769e Mon Sep 17 00:00:00 2001 From: jsc Date: Tue, 17 Dec 2019 12:43:02 +0100 Subject: [PATCH 3/3] Aligns allocation with usage (was unnecessarily large) --- src/convolutional/lookup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convolutional/lookup.c b/src/convolutional/lookup.c index 8c96aae..05af0c2 100644 --- a/src/convolutional/lookup.c +++ b/src/convolutional/lookup.c @@ -25,7 +25,7 @@ pair_lookup_t pair_lookup_create(unsigned int rate, pair_lookup_t pairs; pairs.keys = malloc(sizeof(unsigned int) * (1 << (order - 1))); - pairs.outputs = calloc((1 << (rate * 2)), sizeof(unsigned int)); + pairs.outputs = calloc((1 << (order - 1)) + 1, sizeof(unsigned int)); unsigned int *inv_outputs = calloc((1 << (rate * 2)), sizeof(unsigned int)); unsigned int output_counter = 1; // for every (even-numbered) shift register state, find the concatenated output of the state