Skip to content

Commit

Permalink
free memory in pbacktrack
Browse files Browse the repository at this point in the history
  • Loading branch information
marcom committed Apr 18, 2022
1 parent 8093797 commit 2ca90b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/ViennaRNA.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ include("../lib/LibRNA.jl")
import .LibRNA

module LibRNA_Helper
function free_subopt_solutions(ptr)
function free_subopt_solutions(ptr::Ptr)
ptr == C_NULL && return
i = 1
while true
Expand All @@ -23,6 +23,13 @@ function free_subopt_solutions(ptr)
end
Libc.free(ptr)
end

function free_structure_list(ptr::Ptr, num::Integer)
for i = 1:num
Libc.free(unsafe_load(ptr, i))
end
Libc.free(ptr)
end
end
import .LibRNA_Helper

Expand Down Expand Up @@ -296,6 +303,7 @@ function pbacktrack(fc::FoldCompound;
push!(samples, unsafe_string(unsafe_load(s, i)))
i += 1
end
LibRNA_Helper.free_structure_list(s, num_samples)
return samples
end

Expand Down

0 comments on commit 2ca90b7

Please sign in to comment.