2018-07-12 Niels Möller <nisse@lysator.liu.se>
+ * examples/eratosthenes.c (main): Don't allocate bitmap storage
+ for limit == 2 (early exit), closing memory leak at exit.
+
* eccdata.c (output_curve): Replace mpz_init_set_ui by mpz_set_ui,
to fix memory leak.
(ecc_curve_clear): New function.
root = (root - 1) | 1;
/* Represents odd numbers from 3 up. */
sieve_nbits = (root - 1) / 2;
- sieve = vector_alloc(sieve_nbits );
- vector_init(sieve, sieve_nbits);
if (verbose)
fprintf(stderr, "Initial sieve using %lu bits.\n", sieve_nbits);
if (limit == 2)
return EXIT_SUCCESS;
+ sieve = vector_alloc(sieve_nbits);
+ vector_init(sieve, sieve_nbits);
+
for (bit = 0;
bit < sieve_nbits;
bit = vector_find_next(sieve, bit + 1, sieve_nbits))