@@ -145,8 +145,8 @@ void freedv_fsk_ldpc_open(struct freedv *f, struct freedv_advanced *adv) {
145145
146146 f -> bits_per_modem_frame = f -> ldpc -> data_bits_per_frame ;
147147 int bits_per_frame = f -> ldpc -> coded_bits_per_frame + sizeof (fsk_ldpc_uw );
148- f -> tx_payload_bits = malloc (f -> bits_per_modem_frame ); assert (f -> tx_payload_bits != NULL );
149- f -> rx_payload_bits = malloc (f -> bits_per_modem_frame ); assert (f -> rx_payload_bits != NULL );
148+ f -> tx_payload_bits = MALLOC (f -> bits_per_modem_frame ); assert (f -> tx_payload_bits != NULL );
149+ f -> rx_payload_bits = MALLOC (f -> bits_per_modem_frame ); assert (f -> rx_payload_bits != NULL );
150150
151151 /* sample buffer size for tx modem samples, we modulate a full frame */
152152 f -> n_nom_modem_samples = f -> fsk -> Ts * (bits_per_frame /(f -> fsk -> mode >>1 ));
@@ -163,12 +163,12 @@ void freedv_fsk_ldpc_open(struct freedv *f, struct freedv_advanced *adv) {
163163
164164 /* deframer set up */
165165 f -> frame_llr_size = 2 * bits_per_frame ;
166- f -> frame_llr = (float * )malloc (f -> frame_llr_size * sizeof (float )); assert (f -> frame_llr != NULL );
166+ f -> frame_llr = (float * )MALLOC (f -> frame_llr_size * sizeof (float )); assert (f -> frame_llr != NULL );
167167 f -> frame_llr_nbits = 0 ;
168168
169- f -> twoframes_hard = malloc (2 * bits_per_frame ); assert (f -> twoframes_hard != NULL );
169+ f -> twoframes_hard = MALLOC (2 * bits_per_frame ); assert (f -> twoframes_hard != NULL );
170170 memset (f -> twoframes_hard , 0 , 2 * bits_per_frame );
171- f -> twoframes_llr = (float * )malloc (2 * bits_per_frame * sizeof (float )); assert (f -> twoframes_llr != NULL );
171+ f -> twoframes_llr = (float * )MALLOC (2 * bits_per_frame * sizeof (float )); assert (f -> twoframes_llr != NULL );
172172 for (int i = 0 ; i < 2 * bits_per_frame ; i ++ ) f -> twoframes_llr [i ] = 0.0 ;
173173
174174 /* currently configured a simple frame-frame approach */
@@ -227,7 +227,7 @@ void freedv_tx_fsk_voice(struct freedv *f, short mod_out[]) {
227227 }
228228
229229 /* Allocate floating point buffer for FSK mod */
230- tx_float = alloca (sizeof (float )* f -> n_nom_modem_samples );
230+ tx_float = MALLOC (sizeof (float )* f -> n_nom_modem_samples );
231231
232232 /* do 4fsk mod */
233233 if (FDV_MODE_ACTIVE ( FREEDV_MODE_2400A , f -> mode ) || FDV_MODE_ACTIVE ( FREEDV_MODE_800XA , f -> mode )){
@@ -252,6 +252,8 @@ void freedv_tx_fsk_voice(struct freedv *f, short mod_out[]) {
252252 mod_out [i ] = (short )(tx_float [i ]* FMFSK_SCALE );
253253 }
254254 }
255+
256+ FREE (tx_float );
255257}
256258
257259/* TX routines for 2400 FSK modes, after codec2 encoding */
@@ -297,7 +299,7 @@ void freedv_comptx_fsk_voice(struct freedv *f, COMP mod_out[]) {
297299 }
298300
299301 /* Allocate floating point buffer for FSK mod */
300- tx_float = alloca (sizeof (float )* f -> n_nom_modem_samples );
302+ tx_float = MALLOC (sizeof (float )* f -> n_nom_modem_samples );
301303
302304 /* do 4fsk mod */
303305 if (FDV_MODE_ACTIVE ( FREEDV_MODE_2400A , f -> mode ) || FDV_MODE_ACTIVE ( FREEDV_MODE_800XA , f -> mode )){
@@ -314,6 +316,8 @@ void freedv_comptx_fsk_voice(struct freedv *f, COMP mod_out[]) {
314316 mod_out [i ].real = (tx_float [i ]);
315317 }
316318 }
319+
320+ FREE (tx_float );
317321}
318322
319323/* TX routines for 2400 FSK modes, data channel */
@@ -327,7 +331,7 @@ void freedv_tx_fsk_data(struct freedv *f, short mod_out[]) {
327331 fvhff_frame_data_bits (f -> deframer , FREEDV_VHF_FRAME_A ,(uint8_t * )(f -> tx_bits ));
328332
329333 /* Allocate floating point buffer for FSK mod */
330- tx_float = alloca (sizeof (float )* f -> n_nom_modem_samples );
334+ tx_float = MALLOC (sizeof (float )* f -> n_nom_modem_samples );
331335
332336 /* do 4fsk mod */
333337 if (FDV_MODE_ACTIVE ( FREEDV_MODE_2400A , f -> mode ) || FDV_MODE_ACTIVE ( FREEDV_MODE_800XA , f -> mode )){
@@ -344,6 +348,8 @@ void freedv_tx_fsk_data(struct freedv *f, short mod_out[]) {
344348 mod_out [i ] = (short )(tx_float [i ]* FMFSK_SCALE );
345349 }
346350 }
351+
352+ FREE (tx_float );
347353}
348354
349355int freedv_tx_fsk_ldpc_bits_per_frame (struct freedv * f ) {
0 commit comments