Minor changes. Does not actually affect the outcome.

This commit is contained in:
metallaxis committed 2026-05-07 12:32:30 +03:00
1 parent f7680e872c
commit c34b054f09
3 files changed
+8 -8

No files matched your search

+2 -2
View File
@@ -65,10 +65,10 @@ bool run_bfs(int128_t* sum, int128_t a0, int128_t b0, int128_t c0, int print_mod
print_int128(found->b); printf(", "); print_int128(found->b); printf(", ");
print_int128(found->c); printf(")\n"); print_int128(found->c); printf(")\n");
printf("Moves (%d): %s\n", max_moves, moves); printf("Moves (%i): %s\n", max_moves, moves);
} else if (print_mode == 2) { } else if (print_mode == 2) {
print_int128(c0); print_int128(c0);
printf(" the required amount of moves is: %d\n", max_moves); printf(" the required amount of moves is: %i\n", max_moves);
} }
*sum+=max_moves; *sum+=max_moves;
+2 -4
View File
@@ -23,18 +23,17 @@ void node_pool_init(int32_t max_nodes) {
pool = malloc(pool_capacity * sizeof(Node)); pool = malloc(pool_capacity * sizeof(Node));
visited_pool = malloc(pool_capacity * sizeof(VisitedEntry)); visited_pool = malloc(pool_capacity * sizeof(VisitedEntry));
if (!pool || !visited_pool) { if (!pool || !visited_pool) {
fprintf(stderr, "Fatal: Could not allocate Node Pool for %d nodes.\n", max_nodes); fprintf(stderr, "Fatal: Could not allocate Node Pool for %i nodes.\n", max_nodes);
exit(1); exit(1);
} }
pool_ptr = 0; pool_ptr = 0;
visited_ptr = 0; visited_ptr = 0;
for (size_t i = 0; i < HASH_SIZE; ++i) hash_table[i] = NULL; for (size_t i = 0; i < HASH_SIZE; ++i) hash_table[i] = NULL;
queue_init(max_nodes);
} }
Node* node_pool_alloc() { Node* node_pool_alloc() {
if (pool_ptr >= pool_capacity) { if (pool_ptr >= pool_capacity) {
fprintf(stderr, "\nNode Pool Overflow! Need more than %d nodes.\n", pool_capacity); fprintf(stderr, "\nNode Pool Overflow! Need more than %i nodes.\n", pool_capacity);
return NULL; return NULL;
} }
return &pool[pool_ptr++]; return &pool[pool_ptr++];
@@ -46,7 +45,6 @@ void node_pool_reset() {
void node_pool_destroy() { void node_pool_destroy() {
if (pool) free(pool); if (pool) free(pool);
queue_destroy();
} }
int32_t node_pool_usage() { int32_t node_pool_usage() {
+4 -2
View File
@@ -49,8 +49,9 @@ void clear_global_table() {
} }
int main() { int main() {
// Good for p = 7: 80000000 int32_t max_nodes = 160000000;
node_pool_init(160000000); node_pool_init(max_nodes);
queue_init(max_nodes);
int mode = 0, print_mode = 0; int mode = 0, print_mode = 0;
int128_t a0 = 10, b0 = 6, c0 = 0, sum = 0; int128_t a0 = 10, b0 = 6, c0 = 0, sum = 0;
@@ -109,6 +110,7 @@ int main() {
print_int128(sum); printf("\n"); print_int128(sum); printf("\n");
} }
queue_destroy();
node_pool_destroy(); node_pool_destroy();
return 0; return 0;
} }