a-conjecture-of-mine

An exercise on polyglossy: the same problem solved on multiple languages

Commit
ab68089e4f0a13dda9eeb8d37f9b70f2bee405b2
Parent
b033617f3443e322d7b21f0944c4183fb5651221
Author
Pablo Escobar Gaviria <gark.garcia@protonmail.com>
Date

Cleaned the C implementation.

Diffstat

1 file changed, 1 insertion, 3 deletions

Status File Name N° Changes Insertions Deletions
Modified C/main.c 4 1 3
diff --git a/C/main.c b/C/main.c
@@ -80,9 +80,7 @@ int main(int argc, char *argv[])
         range thread_ranges[n_threads];
 
         // Create the sums cache
-        // Original (2 * max) causing seg faults in multi-threading
-        int sums_c = 3 * max;
-        sums_cache = malloc(sizeof(int) * sums_c);
+        sums_cache = malloc(sizeof(int) * (2 * max + 1));
         for (int i = 0; i <= sums_c; i++)
             sums_cache[i] = sum_digits(i);