Skip to content

Commit 85cf9c6

Browse files
committed
Fix memory leaks
These arose as a result of removing buggy "autofree".
1 parent 6363ca2 commit 85cf9c6

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

test/test_algorithm.F90

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ subroutine test_shuffle()
178178
call rng%release()
179179

180180
! Shuffle using temporary RNG using seed 12345
181-
call shuffle(Engine(12345_c_int32_t), iarr)
181+
rng = Engine(12345_c_int32_t)
182+
call shuffle(rng, iarr)
183+
call rng%release
182184
write(*,"(A,(8I4))") "Shuffled:", iarr
183185
end subroutine
184186

test/test_random.F90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,14 @@ subroutine test_discrete_distribution()
115115
integer(C_INT), dimension(1024) :: sampled
116116
integer(C_INT), dimension(4) :: tallied = 0
117117
integer(C_INT), dimension(4), parameter :: gold_result = [130, 127, 267, 500]
118+
type(Engine) :: rng
118119
integer :: i
119120

120121
! Sample 1024 random ints
121-
call discrete_distribution(weights, Engine(), sampled)
122+
rng = Engine()
123+
call discrete_distribution(weights, rng, sampled)
124+
call rng%release()
125+
122126
ASSERT(minval(sampled) == 1)
123127
ASSERT(maxval(sampled) == size(weights))
124128
do i = 1, size(sampled)

0 commit comments

Comments
 (0)