Added some more useful docs and stuff.
This commit is contained in:
parent
fcee95da17
commit
003b94dcdb
10
src/list.h
10
src/list.h
@ -1,3 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* @file list.h
|
||||||
|
* @author Deathsbreed <deathsbreed@themusicinnoise.net>
|
||||||
|
* @brief Code responsible for List management.
|
||||||
|
* @details Code responsible for the definition and management of the
|
||||||
|
* List object.
|
||||||
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <gmp.h>
|
#include <gmp.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@ -14,8 +21,7 @@ typedef struct {
|
|||||||
/**
|
/**
|
||||||
* @brief Initialize a List.
|
* @brief Initialize a List.
|
||||||
* @details Initialize the list and its variables, allocating memory
|
* @details Initialize the list and its variables, allocating memory
|
||||||
* to the pointer array inside. Returns true on success and false on
|
* to the pointer array inside.
|
||||||
* failure.
|
|
||||||
* @param[in] l A pointer to a List type to be initialized.
|
* @param[in] l A pointer to a List type to be initialized.
|
||||||
*/
|
*/
|
||||||
void initList(List *restrict l);
|
void initList(List *restrict l);
|
||||||
|
10
src/main.c
10
src/main.c
@ -7,6 +7,7 @@
|
|||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
|
||||||
static bool run;
|
static bool run;
|
||||||
|
|
||||||
void leave();
|
void leave();
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
@ -41,7 +42,10 @@ int main(void) {
|
|||||||
do {
|
do {
|
||||||
// Calculate half of `num'
|
// Calculate half of `num'
|
||||||
mpz_fdiv_q_ui(halfNum, num, 2);
|
mpz_fdiv_q_ui(halfNum, num, 2);
|
||||||
// Loop through found primes
|
/**
|
||||||
|
* Loop through primes we've found until we get to half of the number
|
||||||
|
* we're analyzing
|
||||||
|
*/
|
||||||
for(size_t i = 0; mpz_cmp(primes.list[i], halfNum) < 0; ++i) {
|
for(size_t i = 0; mpz_cmp(primes.list[i], halfNum) < 0; ++i) {
|
||||||
// If `num' is divisible by a prime then go to the next number
|
// If `num' is divisible by a prime then go to the next number
|
||||||
if(mpz_divisible_p(num, primes.list[i]) != 0)
|
if(mpz_divisible_p(num, primes.list[i]) != 0)
|
||||||
@ -73,6 +77,4 @@ nextPrime:
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void leave() {
|
void leave() { run = false; }
|
||||||
run = false;
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user