diff --git a/src/list.c b/src/list.c index 8801b02..51bfc48 100644 --- a/src/list.c +++ b/src/list.c @@ -21,6 +21,9 @@ void initList(List *l) { } void deInitList(List *l) { + for(ulli i = 0; i < l->size; ++i) { + mpz_clear(l->list[i]); + } free(l->list); } @@ -29,7 +32,7 @@ void addToList(List *l, mpz_t n) { l->size += BLOCK_SIZE; if(unlikely(l->size == 0)) { fprintf(stderr, - "size has reached limit of `long long int' type!\n"); + "Size has reached limit of `long long int' type!\n"); exit(1); } void *tmp = realloc(l->list, sizeof(mpz_t) * l->size); diff --git a/src/main.c b/src/main.c index ed056d0..60e5990 100644 --- a/src/main.c +++ b/src/main.c @@ -40,7 +40,8 @@ int main(void) { // Loop through found primes for(ulli i = 0; i < primes.size; ++i) { // If `num' is divisible by a prime then go to the next number - if(mpz_divisible_p(num, primes.list[i]) != 0) goto nextPrime; + if(mpz_divisible_p(num, primes.list[i]) != 0) + goto nextPrime; } // `num' is a prime so we add it to the list and print it @@ -56,6 +57,7 @@ nextPrime: mpz_add_ui(num, num, 2); } while(likely(run)); + mpz_clear(num); // Deinitialize the list deInitList(&primes); return 0;