Valgrind reports:
==2052526== Conditional jump or move depends on uninitialised value(s)
==2052526== at 0x1B547D: pg::Game::set_priority(int, int) (game.cpp:276)
==2052526== by 0x1B52EE: pg::Game::init_vertex(int, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (game.cpp:263)
==2052526== by 0x1B4FD4: pg::Game::init_random_game(int, long, long) (game.cpp:227)
==2052526== by 0x12329D: main (test_solvers.cpp:405)
This is the offending line:
|
else if (node < (n_vertices-1) and _priority[node] > _priority[node+1]) is_ordered = false; |
This is because _priority is not calloced but malloced here:
|
_priority = (int*)malloc(sizeof(int[v_allocated])); |
This should read:
_priority = (int*)calloc(v_allocated, sizeof(int));
(Or better yet, as this is C++:
_priority = new int[v_allocated] {};
)
Valgrind reports:
This is the offending line:
oink/src/game.cpp
Line 276 in 257d0d0
This is because
_priorityis notcalloced butmalloced here:oink/src/game.cpp
Line 127 in 257d0d0
This should read:
(Or better yet, as this is C++:
)