From 5bbac132bc0166b3584bb93a135bd9d4b974b3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20A=2E=20Ortega?= Date: Wed, 14 Dec 2016 14:13:32 +0100 Subject: [PATCH] Use size_t, which is better for arrays of very large sizes. --- src/list.c | 2 +- src/list.h | 6 ++---- src/main.c | 3 +-- src/types.h | 2 -- 4 files changed, 4 insertions(+), 9 deletions(-) delete mode 100644 src/types.h diff --git a/src/list.c b/src/list.c index 44d2b81..1d35ef0 100644 --- a/src/list.c +++ b/src/list.c @@ -19,7 +19,7 @@ void initList(List *restrict l) { } void deInitList(List *restrict l) { - for(ulli i = 0; i < l->size; ++i) { + for(size_t i = 0; i < l->size; ++i) { mpz_clear(l->list[i]); } free(l->list); diff --git a/src/list.h b/src/list.h index 2857433..272a4ea 100644 --- a/src/list.h +++ b/src/list.h @@ -2,15 +2,13 @@ #include #include -#include "types.h" - /** * @brief An infinitely expanding list type. */ typedef struct { mpz_t *list; //!< The list of elements - ulli size; //!< How many elements are in the list - ulli end; //!< The last element of the list (in use) + size_t size; //!< How many elements are in the list + size_t end; //!< The last element of the list (in use) } List; /** diff --git a/src/main.c b/src/main.c index 00e1676..a4506fa 100644 --- a/src/main.c +++ b/src/main.c @@ -5,7 +5,6 @@ #include #include "list.h" -#include "types.h" static bool run; void leave(); @@ -43,7 +42,7 @@ int main(void) { // Calculate half of `num' mpz_fdiv_q_ui(halfNum, num, 2); // Loop through found primes - for(ulli i = 0; i < primes.end; ++i) { + for(size_t i = 0; i < primes.end; ++i) { if(mpz_cmp(primes.list[i], halfNum) > 0) break; // If `num' is divisible by a prime then go to the next number if(mpz_divisible_p(num, primes.list[i]) != 0) diff --git a/src/types.h b/src/types.h deleted file mode 100644 index 9de6f13..0000000 --- a/src/types.h +++ /dev/null @@ -1,2 +0,0 @@ -#pragma once -typedef unsigned long long int ulli;