summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJaron Kent-Dobias <jaron@kent-dobias.com>2017-10-18 17:00:53 -0400
committerJaron Kent-Dobias <jaron@kent-dobias.com>2017-10-18 17:00:53 -0400
commit58b74c50c3b23a008e5e3f4f5bef3edaae1418e6 (patch)
treeeb2a6ed1c796004aae1885a9575bee7a9175f9fe
parent1e8779cbc8d9497b6622f93fd52dd3b918967a6e (diff)
downloadc++-58b74c50c3b23a008e5e3f4f5bef3edaae1418e6.tar.gz
c++-58b74c50c3b23a008e5e3f4f5bef3edaae1418e6.tar.bz2
c++-58b74c50c3b23a008e5e3f4f5bef3edaae1418e6.zip
fixed memory leak due to not emptying stack in the case where the cluster flip is accepted in the hybrid method
-rw-r--r--lib/wolff_tools.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/wolff_tools.c b/lib/wolff_tools.c
index 6b1e006..bab0908 100644
--- a/lib/wolff_tools.c
+++ b/lib/wolff_tools.c
@@ -206,6 +206,9 @@ uint32_t wolff_step(double T, double H, ising_state_t *s, sim_t sim, gsl_rng *r,
s->spins[v] = !s->spins[v];
}
} else {
+ while (c->spins != NULL) {
+ stack_pop(&(c->spins));
+ }
s->M += - sign(H) * 2 * c->dHb;
s->H += 2 * (c->dJb + sign (H) * H * c->dHb);
}