Fixed some memory leaks.
This commit is contained in:
parent
94248612ba
commit
2b5541d2c3
@ -15,6 +15,8 @@ int inputPrimes(char *file, List *list) {
|
||||
while(mpz_inp_raw(n, in))
|
||||
if(addToList(list, n) == 1) return 3;
|
||||
|
||||
mpz_clear(n);
|
||||
|
||||
if(fclose(in)) return 2;
|
||||
return 0;
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ int initList(List *restrict l) {
|
||||
}
|
||||
|
||||
void deInitList(List *restrict l) {
|
||||
for(size_t i = 0; i < l->size; ++i) {
|
||||
for(size_t i = 0; i < l->end; ++i) {
|
||||
mpz_clear(l->list[i]);
|
||||
}
|
||||
free(l->list);
|
||||
|
@ -199,6 +199,7 @@ int main(int argc, char *argv[]) {
|
||||
while(mpz_cmp(primes.list[rootInd], numRoot) <= 0) {
|
||||
if(++rootInd > primes.end) {
|
||||
fprintf(stderr, "Error: `rootInd' surpassed `primes.end'.\n");
|
||||
exitCode = 1;
|
||||
goto releaseMemory;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user