check out memory allocation

dev
xufulong 3 years ago
parent 1b61ad59ed
commit 4ae77b69c9
  1. 5
      app/src/main/cpp/visualizer/execute_fft.cpp

@ -193,6 +193,7 @@ int init_visualizer(filter_sys_t *p_filter)
p_filter->p_prev_s16_buff = nullptr; p_filter->p_prev_s16_buff = nullptr;
auto *w_param = (window_param*) malloc(sizeof(window_param)); auto *w_param = (window_param*) malloc(sizeof(window_param));
if (!w_param) return -1;
p_filter->wind_param = *w_param; p_filter->wind_param = *w_param;
/* Fetch the FFT window parameters */ /* Fetch the FFT window parameters */
@ -207,8 +208,12 @@ int init_visualizer(filter_sys_t *p_filter)
p_filter->out_samples = FFT_BUFFER_SIZE; p_filter->out_samples = FFT_BUFFER_SIZE;
#endif #endif
p_filter->output = (int8_t *) (malloc(p_filter->out_samples * sizeof(int8_t))); p_filter->output = (int8_t *) (malloc(p_filter->out_samples * sizeof(int8_t)));
if (!p_filter->output) return -1;
p_filter->data_size = MAX_FFT_SIZE; p_filter->data_size = MAX_FFT_SIZE;
p_filter->data = (uint8_t *) (malloc(MAX_FFT_SIZE * sizeof(uint8_t))); p_filter->data = (uint8_t *) (malloc(MAX_FFT_SIZE * sizeof(uint8_t)));
if (!p_filter->data) {
return -1;
}
return 0; return 0;
} }

Loading…
Cancel
Save