Skip to content

Commit 396f5b2

Browse files
committed
fix: ensure that the table of kernel functions are zero-initialized
1 parent b6125d1 commit 396f5b2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/colvarcomp_coordnums.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,12 @@ namespace {
573573
else return funcs_[select<flags>()][n-1][m-1];
574574
}
575575

576+
void init_funcs_to_nullptr() {
577+
std::memset(funcs_, 0, sizeof(compute_pair_coordnum_type)*16*12*12);
578+
}
579+
576580
template <int n, int m>
577581
void set_func() {
578-
for (int i = 0; i < 16; ++i) {
579-
funcs_[i][n-1][m-1] = nullptr;
580-
}
581-
582582
funcs_[select<colvar::coordnum::ef_gradients>()][n-1][m-1] =
583583
&colvar::selfcoordnum::selfcoordnum_sequential_loop<colvar::coordnum::ef_gradients, n, m>;
584584
funcs_[select<colvar::coordnum::ef_use_internal_pbc>()][n-1][m-1] =
@@ -659,6 +659,7 @@ colvar::selfcoordnum::selfcoordnum()
659659
{
660660
set_function_type("selfCoordNum");
661661
// NOTE: I only enable the most commonly used template since enabling too many of them would slow down the compilation...
662+
init_funcs_to_nullptr();
662663
// set_func<1, 1>();
663664
// set_func<1, 2>();
664665
// set_func<1, 3>();

0 commit comments

Comments
 (0)