Skip to content

Commit

Permalink
Merge pull request #1 from itrharrison/bug-memory_leaks
Browse files Browse the repository at this point in the history
address memory leak: added frees to get_ python functions
  • Loading branch information
itrharrison authored Aug 3, 2022
2 parents 468d794 + 707e070 commit 5de3617
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions hi_class_public/python/classy.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,9 @@ cdef class Class:
for index in range(timesteps):
background[names[i]][index] = data[index*number_of_titles+i]

free(titles)
free(data)

return background

def get_thermodynamics(self):
Expand Down Expand Up @@ -1058,6 +1061,9 @@ cdef class Class:
for index in range(timesteps):
thermodynamics[names[i]][index] = data[index*number_of_titles+i]

free(titles)
free(data)

return thermodynamics

def get_primordial(self):
Expand Down Expand Up @@ -1094,6 +1100,9 @@ cdef class Class:
for index in range(timesteps):
primordial[names[i]][index] = data[index*number_of_titles+i]

free(titles)
free(data)

return primordial


Expand Down Expand Up @@ -1244,6 +1253,9 @@ cdef class Class:
else:
spectra[ic_key] = tmpdict

free(titles)
free(data)

return spectra


Expand Down

0 comments on commit 5de3617

Please sign in to comment.