Skip to content

Commit

Permalink
Remove dynamic memory allocation from initialization of the `pyrodiga…
Browse files Browse the repository at this point in the history
…l._pyrodigal` module
  • Loading branch information
althonos committed Oct 22, 2022
1 parent 04059a0 commit aba7b68
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions pyrodigal/_pyrodigal.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4356,13 +4356,12 @@ cdef class MetagenomicBin:
return self.bin.desc.decode('ascii')

# Allocate raw C memory for the C structs
cdef _training _METAGENOMIC_TRAINING_INFO[NUM_META]
cdef _metagenomic_bin _METAGENOMIC_BINS[NUM_META]
cdef ssize_t _i
for _i in range(NUM_META):
memset(&_METAGENOMIC_BINS[_i], 0, sizeof(_metagenomic_bin))
_METAGENOMIC_BINS[_i].tinf = <_training*> PyMem_Malloc(sizeof(_training))
if not _METAGENOMIC_BINS[_i].tinf:
raise MemoryError()
_METAGENOMIC_BINS[_i].tinf = &_METAGENOMIC_TRAINING_INFO[_i]
memset(_METAGENOMIC_BINS[_i].tinf, 0, sizeof(_training))
initialize_metagenomic_bins(_METAGENOMIC_BINS)

Expand Down

0 comments on commit aba7b68

Please sign in to comment.