From 07bb0fd7edd736aa76d90ae0fa13e60e31114191 Mon Sep 17 00:00:00 2001 From: Georgios Chatzopoulos Date: Fri, 29 May 2026 17:20:53 +0300 Subject: [PATCH] Minor changes. --- run.sh | 1 + src/bfs.c | 5 ++++- src/node.c | 20 +++++++++++--------- 3 files changed, 16 insertions(+), 10 deletions(-) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..2556f2d --- /dev/null +++ b/run.sh @@ -0,0 +1 @@ +make && echo -e "2\n2\n" | time ./bin/stergios diff --git a/src/bfs.c b/src/bfs.c index 180fdbe..62e7a79 100644 --- a/src/bfs.c +++ b/src/bfs.c @@ -72,6 +72,9 @@ bool run_bfs(int128_t* sum, int128_t a0, int128_t b0, int128_t c0, int print_mod } *sum+=max_moves; - if (print_mode == 1) free(moves); + if (print_mode == 1) { + free(moves); + moves = NULL; + } return true; } \ No newline at end of file diff --git a/src/node.c b/src/node.c index 535adf9..9cc1eea 100644 --- a/src/node.c +++ b/src/node.c @@ -44,7 +44,14 @@ void node_pool_reset() { } void node_pool_destroy() { - if (pool) free(pool); + if (pool) { + free(pool); + pool = NULL; + } + if (visited_pool) { + free(visited_pool); + visited_pool = NULL; + } } int32_t node_pool_usage() { @@ -84,18 +91,13 @@ void try_push_children(Node* curr) { make_move('A', curr); make_move('B', curr); make_move('C', curr); - return; - } - - if (last == 'A') { + } else if (last == 'A') { make_move('C', curr); make_move('B', curr); - } - else if (last == 'B') { + } else if (last == 'B') { make_move('C', curr); make_move('A', curr); - } - else if (last == 'C') { + } else if (last == 'C') { make_move('B', curr); make_move('A', curr); }