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 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) { 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