Skip to content

Commit

Permalink
Remove unnecessary m_malloc_fail and deinit from memory allocation …
Browse files Browse the repository at this point in the history
…routines.
  • Loading branch information
relic-se committed Nov 8, 2024
1 parent 5f8ec0a commit c96d142
Showing 1 changed file with 0 additions and 16 deletions.
16 changes: 0 additions & 16 deletions shared-module/audiofilters/Filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,15 @@ void common_hal_audiofilters_filter_construct(audiofilters_filter_obj_t *self,
self->buffer_len = buffer_size; // in bytes

self->buffer[0] = m_malloc(self->buffer_len);
if (self->buffer[0] == NULL) {
common_hal_audiofilters_filter_deinit(self);
m_malloc_fail(self->buffer_len);
}
memset(self->buffer[0], 0, self->buffer_len);

self->buffer[1] = m_malloc(self->buffer_len);
if (self->buffer[1] == NULL) {
common_hal_audiofilters_filter_deinit(self);
m_malloc_fail(self->buffer_len);
}
memset(self->buffer[1], 0, self->buffer_len);

self->last_buf_idx = 1; // Which buffer to use first, toggle between 0 and 1

// This buffer will be used to process samples through the biquad filter
self->filter_buffer = m_malloc(SYNTHIO_MAX_DUR * sizeof(int32_t));
if (self->filter_buffer == NULL) {
common_hal_audiofilters_filter_deinit(self);
m_malloc_fail(SYNTHIO_MAX_DUR * sizeof(int32_t));
}
memset(self->filter_buffer, 0, SYNTHIO_MAX_DUR * sizeof(int32_t));

// Initialize other values most effects will need.
Expand Down Expand Up @@ -106,10 +94,6 @@ void reset_filter_states(audiofilters_filter_obj_t *self) {
}

self->filter_states = m_malloc(self->filter_states_len * sizeof(biquad_filter_state));
if (self->filter_states == NULL) {
common_hal_audiofilters_filter_deinit(self);
m_malloc_fail(self->filter_states_len * sizeof(biquad_filter_state));
}

if (mp_obj_is_type(items, (const mp_obj_type_t *)&synthio_biquad_type_obj)) {
synthio_biquad_filter_assign(&self->filter_states[0], items);
Expand Down

0 comments on commit c96d142

Please sign in to comment.